Click here to Skip to main content
15,905,971 members
Home / Discussions / Visual Basic
   

Visual Basic

 
NewsHello everybody Pin
Borun12-Dec-05 10:06
Borun12-Dec-05 10:06 
GeneralRe: Hello everybody Pin
Steve Pullan12-Dec-05 12:49
Steve Pullan12-Dec-05 12:49 
GeneralRe: Hello everybody Pin
Borun13-Dec-05 3:10
Borun13-Dec-05 3:10 
GeneralRe: Hello everybody Pin
Curtis Schlak.13-Dec-05 4:46
Curtis Schlak.13-Dec-05 4:46 
QuestionRegistry entries don't show up Regedit, but are set in UI in VS Pin
depotdog12-Dec-05 7:21
depotdog12-Dec-05 7:21 
QuestionHTTPS credentials with proxy? Pin
matsnas12-Dec-05 3:14
matsnas12-Dec-05 3:14 
QuestionNeed a button that works Pin
patrick king12-Dec-05 2:52
patrick king12-Dec-05 2:52 
AnswerRe: Need a button that works Pin
MarcelErz12-Dec-05 4:30
MarcelErz12-Dec-05 4:30 
HI!


You can create a new instance of the Button-class. Here an example:

' Counter for all buttons
Dim liButtonCount As Integer = 0

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' create new button
Dim foNewButton As New System.Windows.Forms.Button()

With foNewButton
' give the new object a name to find out which button pressed later
.Name = "NewButton" + liButtonCount.ToString

' set some properties like text, size and location
.Text = "NewButton " + liButtonCount.ToString
.Location = New System.Drawing.Point(1, liButtonCount * 40)
.Size = New System.Drawing.Size(120, 40)

.Visible = True ' set it as visible

' add the new button to the control list of the container (the formular)
Me.Controls.Add(foNewButton)

' add the destination sub to the event handler of the button (execute sub when get fired)
AddHandler .Click, AddressOf NewButtons_Click
End With

' increment the counter for the next new button
liButtonCount = liButtonCount + 1
End Sub

' multiple event sub for all dynamical created buttons
Private Sub NewButtons_Click(ByVal sender As Object, ByVal e As System.EventArgs)
' just to work easier with the object
Dim loButton As System.Windows.Forms.Button = sender

' find out which button was pressed
Select Case loButton.Name
Case "NewButton0" : MessageBox.Show("This is new Button number 0")
Case "NewButton1" : MessageBox.Show("And this is new Button number 1")
' you can go on like this for every button...
End Select
End Sub

I hope I could help you! If you need more help with it, just let me know!

Marcel Erz
AnswerRe: Need a button that works Pin
Christian Graus12-Dec-05 12:29
protectorChristian Graus12-Dec-05 12:29 
Questionhow do you set an item to be selected in the combobox in vb6? Pin
bonosa12-Dec-05 2:49
bonosa12-Dec-05 2:49 
AnswerRe: how do you set an item to be selected in the combobox in vb6? Pin
MarcelErz12-Dec-05 3:53
MarcelErz12-Dec-05 3:53 
AnswerRe: how do you set an item to be selected in the combobox in vb6? Pin
AminMaredia13-Dec-05 21:29
AminMaredia13-Dec-05 21:29 
GeneralRe: how do you set an item to be selected in the combobox in vb6? Pin
bonosa14-Dec-05 15:06
bonosa14-Dec-05 15:06 
Questionmodifying dll Pin
uktrips00712-Dec-05 0:06
uktrips00712-Dec-05 0:06 
AnswerRe: modifying dll Pin
Gerben Jongerius13-Dec-05 4:16
Gerben Jongerius13-Dec-05 4:16 
Questionerror in regenerating pdb file Pin
uktrips00711-Dec-05 20:40
uktrips00711-Dec-05 20:40 
AnswerRe: error in regenerating pdb file Pin
Dave Kreskowiak12-Dec-05 5:48
mveDave Kreskowiak12-Dec-05 5:48 
JokeRe: error in regenerating pdb file Pin
uktrips00713-Dec-05 0:03
uktrips00713-Dec-05 0:03 
QuestionHTML report in VB 6.0 Pin
tusar12311-Dec-05 20:15
tusar12311-Dec-05 20:15 
AnswerRe: HTML report in VB 6.0 Pin
uktrips00711-Dec-05 20:33
uktrips00711-Dec-05 20:33 
AnswerRe: HTML report in VB 6.0 Pin
MarcelErz12-Dec-05 4:32
MarcelErz12-Dec-05 4:32 
QuestionPrinting with vb.net (Urgent) Pin
HemaRawat11-Dec-05 20:06
HemaRawat11-Dec-05 20:06 
AnswerRe: Printing with vb.net (Urgent) Pin
uktrips00711-Dec-05 20:53
uktrips00711-Dec-05 20:53 
GeneralRe: Printing with vb.net (Urgent) Pin
HemaRawat11-Dec-05 21:05
HemaRawat11-Dec-05 21:05 
GeneralRe: Printing with vb.net (Urgent) Pin
uktrips00711-Dec-05 23:16
uktrips00711-Dec-05 23:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.