VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create Controls at Runtime and Capture Events

by �e7eN (23 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

This code will show you how to easily Create Controls at runtime and Capture there events 'With-out' useing API :).
This code will show you how to add a command button and display a message box when its clicked. Please Vote and Post Comments!!

Assumes
'Here are some more control Names '"VB.Label" '"VB.TextBox" '"VB.ListBox" '"VB.ComboBox" '"VB.OptionButton" '"VB.CheckBox"

Rate Create Controls at Runtime and Capture Events

Public WithEvents Command1 As CommandButton
Private Sub Command1_Click()
MsgBox "Button Pressed"
End Sub
Private Sub Form_Load()
Set Command1 = Me.Controls.Add("VB.CommandButton", "Command1", Me)
With Command1
.Visible = True
.Width = 900
.Height = 900
.Left = Me.Width / 2 - .Width / 2
.Top = Me.Height / 2 - .Height / 2
.Caption = "Test Button"
End With
End Sub

Download this snippet    Add to My Saved Code

Create Controls at Runtime and Capture Events Comments

No comments have been posted about Create Controls at Runtime and Capture Events. Why not be the first to post a comment about Create Controls at Runtime and Capture Events.

Post your comment

Subject:
Message:
0/1000 characters