Multiple dialog boxes

Nicko101

Member
Joined
Aug 31, 2004
Messages
10
Programming Experience
Beginner
My problem is this.: I have the following code in my form;

VB.NET:
Dim add As New Form2() 
add.ShowDialog(Me)

If add.ShowDialog = DialogResult.OK Then

quit = 0

End If
This should open form2, then, depending on which button is pressed, should either set quit (integer) to 0. but when i run my program, and click the button to activate this code, the form2 displays correctly, i click the button to set quit, then the dialog box closes, then reappears. i then click the button again, it goes away and sets quit. Why and what am i doing wrong?
 

Schenz

Well-known member
Joined
Sep 11, 2004
Messages
181
Location
Cincinnati, OH
Programming Experience
5-10
Try the following:

Dim add As New Form2()
' Commented out the following line
'add.ShowDialog(Me)

' This line should display the form and store the result.
If add.ShowDialog = DialogResult.OK Then

quit = 0

End If
 

Nicko101

Member
Joined
Aug 31, 2004
Messages
10
Programming Experience
Beginner
That works great thanks! I didnt realise that both the add.showdialog and the If statement displayed the dialog box.
 
Top Bottom