Share Mở Form mới trong ứng dụng VB.NET

** Cách mở biểu mẫu mới trong vb.net **

Trong hướng dẫn này, bạn sẽ học cách mở một biểu mẫu mới trong ứng dụng VB.NET.

## 1. Tạo một dự án mới

Để bắt đầu, mở Visual Studio và tạo một dự án mới.Đối với hướng dẫn này, chúng tôi sẽ tạo một ứng dụng Windows Forms.

## 2. Thêm một biểu mẫu mới

Khi dự án được tạo, bạn sẽ cần thêm một biểu mẫu mới vào dự án.Để thực hiện việc này, nhấp chuột phải vào cửa sổ ** "Giải pháp Explorer" ** và chọn ** "Thêm" **> ** "Mục mới" **.Trong hộp thoại ** "Thêm mục mới" **, chọn ** "Biểu mẫu Windows" ** và nhấp vào ** "Thêm" **.

## 3. Thêm nút vào biểu mẫu

Bây giờ bạn có một biểu mẫu mới, bạn cần thêm một nút vào biểu mẫu.Để thực hiện việc này, kéo và thả điều khiển ** "nút" ** từ ** "Hộp công cụ" ** xuống biểu mẫu.

## 4. Đặt trình xử lý sự kiện nhấp vào nút

Tiếp theo, bạn cần đặt ** "Nhấp vào" ** Trình xử lý sự kiện.Để làm điều này, nhấp đúp vào nút.Điều này sẽ mở cửa sổ ** "Trình chỉnh sửa mã" ** và tạo phương thức xử lý sự kiện ** "nhấp vào" **.

## 5. Viết mã để mở biểu mẫu mới

Trong ** "Nhấp vào" ** Phương thức xử lý sự kiện, bạn cần viết mã để mở biểu mẫu mới.Để làm điều này, bạn có thể sử dụng mã sau:

`` `
Nút phụ riêng1_click (người gửi dưới dạng đối tượng, e là EventArgs) Nút tay cầm1.Click
'Tạo một biểu mẫu mới.
Dim Newform dưới dạng Mẫu2 mới

'Hiển thị hình thức mới.
newform.show ()
Kết thúc phụ
`` `

## 6. Chạy ứng dụng

Bây giờ bạn đã viết mã để mở một biểu mẫu mới, bạn có thể chạy ứng dụng.Để làm điều này, nhấn ** f5 **.

Khi ứng dụng chạy, bạn sẽ thấy biểu mẫu đầu tiên.Nếu bạn nhấp vào nút, bạn sẽ thấy biểu mẫu thứ hai mở.

## 5 hashtags

* #vb.net
* #Windows Forms
* #Hình thức
* #Hình thức mới
* Mẫu #open
=======================================
**How to Open a New Form in VB.NET**

In this tutorial, you will learn how to open a new form in a VB.NET application.

## 1. Create a new project

To begin, open Visual Studio and create a new project. For this tutorial, we will create a Windows Forms application.

## 2. Add a new form

Once the project is created, you will need to add a new form to the project. To do this, right-click on the **"Solution Explorer"** window and select **"Add"** > **"New Item"**. In the **"Add New Item"** dialog box, select **"Windows Form"** and click **"Add"**.

## 3. Add a button to the form

Now that you have a new form, you need to add a button to the form. To do this, drag and drop a **"Button"** control from the **"Toolbox"** onto the form.

## 4. Set the button's Click event handler

Next, you need to set the button's **"Click"** event handler. To do this, double-click on the button. This will open the **"Code Editor"** window and create a **"Click"** event handler method.

## 5. Write the code to open a new form

In the **"Click"** event handler method, you need to write the code to open a new form. To do this, you can use the following code:

```
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Create a new form.
Dim newForm As New Form2

' Show the new form.
newForm.Show()
End Sub
```

## 6. Run the application

Now that you have written the code to open a new form, you can run the application. To do this, press **F5**.

When the application runs, you will see the first form. If you click on the button, you will see the second form open.

## 5 Hashtags

* #vb.net
* #Windows forms
* #form
* #New form
* #open form
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top