In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to create controls directly with code in VB language. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.
How to create a control directly with code
Withevents keyword
What it does: you can declare a control directly, and you can use the events of this control
Controls.add method
Explanation:
Controls control
Add method with two parameters (parameter 1, parameter 2)
Parameter 1: represented by control types such as vb.timer vb.label that already exist in the system
Parameter 2: name of the control
Assignment of variable control
1. If it is an ordinary variable (integer,string,boolean, etc.), the declaration uses dim, and you can assign values directly.
2. If it is an object-type variable, you must use the set keyword when assigning values.
Private keyword
This keyword, which specifies the current variable or class, can only be used in the current form or module or class, and cannot exceed this scope of application.
The interface of this issue:
Source code for this issue:
Private WithEvents label1 As Label 'declares a control with events Private WithEvents timer1 As TimerDim d As Integer' 0 to the right and 1 to the left
Private Sub Form_Load () AutoRedraw = True' instantiates the label control Set label1 = Controls.Add ("vb.label", "label1")
'start configuring the control label1.Caption = "Liu Jinyu programming" label1.FontSize = 50label1.BackColor = vbRedlabel1.AutoSize = Truelabel1.ForeColor = vbWhitelabel1.Left = ScaleWidth / 2-label1.Width / 2label1.Top = ScaleHeight / 2-label1.Height / 2label1.Visible = True 'display control
Set timer1 = Controls.Add ("vb.timer", "timer1") timer1.Interval = 10timer1.Enabled = True
End Sub
Private Sub label1_Click () Shell "explorer http://ljy.kim"End Sub
Private Sub timer1_Timer () If label1.Left + label1.Width > ScaleWidth And d = 0 Then d = 1 'left ElseIf label1.Left < 0 And d = 1 Then d = 0' right End If
If d = 0 Then 'right label1.Left = label1.Left + 10Else label1.Left = label1.Left-10End If
End Sub
The above is how to use the code to create controls directly in the VB language shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.