Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use form forms and controls in VB language

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use form forms and controls in VB language. It is very detailed and has a certain reference value. Friends who are interested must read it!

I. several questions about the examination

First of all, ask: what is the most important thing in the exam?

The answer is actually very simple: score!

If you want to score, you have to keep it basically.

Which files should be saved?

1. File for form code frm extension

two。 Project file vbp extension

3. Application file exe extension

How do I view the file extension?

Organize-folder and search options-View-remove the box "hide extensions of known types"

A state of mind about reporting mistakes?

Grasp the correct attitude and regard error reporting as a guide to help us solve the problem.

To start the timer clock, there must be two main points:

1. Configure the interval internal in milliseconds, 1 second = 1000 milliseconds

two。 Whether the configuration can be run only if you are familiar with enabled as true. If it is false, then it will not run.

Second, basic review of knowledge points

Event for initializing loading of form forms: Form_Load

How to set the font of the label tag through the code?

About font configuration:

FontName sets font type

FontSize sets font size

FontBold sets font bold

FontItalic sets font tilt

FontUnderline sets font with underline

FontStrikethru sets the delete line of the font

How to use it:

Label1.FontName = "Chinese line letters"

Label1.FontSize = 60

Label1.FontBold = True

Label1.FontItalic = True

Label1.FontUnderline = True

Label1.FontStrikethru = True

Third, learn a new control

Listbox list box

The control list location where the listbox is located

In listbox, the content added is item by item, and we can take out or add the contents of the list box separately.

Question: how to enter attributes continuously?

The content of each project is entered in the list property

You need to hold down the shortcut key ctrl+enter to proceed to the next entry.

However, in fact, in a project, it is more likely to add a project to the listbox in the code.

The code adds an item, which is added through the AddItem method.

How to use it:

List control object .AddItem string type

Get the project in the listbox control

Get it through the list attribute, and note that the list property is an array.

The index of the array starts at 0 by default.

So the index of the first item is 0

The index of the second item is 1

How to use it:

List1.List (fill in the index items here)

Delete an item from listbox and use the function RemoveItem

How to use it:

List1.RemoveItem fill in the index to be deleted here.

ListIndex represents the index of the selected row in the current listbox.

When the value of listindex is-1, the item in listbox is not selected.

Therefore, we can make friendly reminders through the judgment of this value to prevent reporting errors!

Judge the code:

If List1.ListIndex =-1 Then

MsgBox "Please select project"

Else

List1.RemoveItem List1.ListIndex

End If

Question: if a major has five classes, what if we add five classes at a time?

For example: professional "18 software", after clicking the "add" button, 18 software 1, 18 software 2, 18 software 3, 18 software 4, 18 software 5 will appear immediately in listbox

Through the for loop to achieve.

For I = 1 To 5 Step 1

List1.AddItem Text1.Text & I

Next i

The relevant source code for this tutorial:

List of project files:

Form1 form design:

Form1

Form1 source code:

Private Sub Form_Load () Label1.FontName = "Chinese script" Label1.FontSize = 60Label1.FontBold = TrueLabel1.FontItalic = TrueLabel1.FontUnderline = TrueLabel1.FontStrikethru = TrueEnd Sub

Private Sub Timer1_Timer ()

If Label1.Caption = "0" Then Timer1.Enabled = False Form2.Show Form1.HideElse Label1.Caption = Val (Label1.Caption)-1End If

End Sub

Form2 interface design:

Form2

Form2 source code:

Private Sub Command1_Click () For I = 1 To 5 Step 1 List1.AddItem Text1.Text & iNext I

End Sub

Private Sub Command2_Click () If List1.ListIndex =-1 Then MsgBox "Please select project" Else List1.RemoveItem List1.ListIndex

End IfEnd Sub

Private Sub Command3_Click () MsgBox List1.List (1) End Sub

The above is all the content of the article "how to use form forms and controls in VB language". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report