online dating service
REGISTER | MAIL/PROFILE | HELP | NOW ONLINE | SEARCH | RATING | FORUMS | SUCCESS STORIES

 

Plentyoffish dating forums are a place to meet singles and get dating advice or share dating experiences etc. Hopefully you will all have fun meeting singles and try out this online dating thing... Remember that we are the largest 100% free online dating service, so you will never have to pay a dime to meet your soulmate.
     
Show ALL Forums  > Technology/Computers  > VB help      Mod Threads Home login  
Page 1 of 1
 Author Thread: VB help
 airhead25

Joined: 5/7/2009
Msg: 1
view profile
History
VB help
Posted: 8/18/2009 7:28:53 PM
I'm having a problem with VB on msgboxresult. when i run this code it doesn't matter which button the user presses. yes or no. it still executes both statements when i only want it to execute the one the user chooses. both prompts come up... "you clicked no" and later "you clicked yes" and the test files get deleted either way. here is the code. if anyone knows how to fix this please help thanks

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
MsgBox("Are you sure you want to permanently delete these files?", MsgBoxStyle.YesNo)
If MsgBoxResult.No Then
MsgBox("you clicked no!")
End If
If MsgBoxResult.Yes Then
MsgBox("You clicked yes!")
End If
End Sub
 - don

Joined: 4/23/2009
Msg: 2
VB help
Posted: 8/18/2009 8:16:04 PM
I'm not a programmer but I did stay at a Holiday Inn Express last night ;-)

MsgBox("Are you sure you want to permanently delete these files?", MsgBoxStyle.YesNo)
If MsgBoxResult.No Then
MsgBox("you clicked no!")
End If
If MsgBoxResult.Yes Then
MsgBox("You clicked yes!")
End If
End Sub
_____________________________________
http://www.w3schools.com/VBScript/vbscript_conditionals.asp



Function greeting()
i=hour(time)
If i < 10 Then
document.write("Good morning!")
Else <------------------------------------------- probably need the Else
document.write("Have a nice day!")
End If
End Function
< /script >
 subtlecaffeine

Joined: 5/23/2007
Msg: 3
view profile
History
VB help
Posted: 8/18/2009 8:26:05 PM
I took a very basic VB class in high school..and soon after I started I picked up a copy of "Teach yourself Visual Basic 6" (shows how outdated I am).

Anyway, I wrote a few programs...I wish I had kept doing stuff, I hear VB got pretty powerful.

You formed your if/then statements wrong. Since you have a yes/no dialog box, you really only need to specify if one action = this then do.whatever else do.other.action - if you had more than two options to choose from...i really don't remember how you'd do it, i'd probably run an if/then, set the else to go to the next subset...or something....

If MsgBoxResult.Yes
Then MsgBox("You clicked yes!")
Else MsgBox("You clicked no!")
End If
End Sub

Probably something like this might even work...maybe...my head says if i typed this in to vb studio it'd let me know I was wrong

If MsgBoxResult.Yes
Then MsgBox("You clicked yes!")
Else End If
End If
If MsgBoxResult.No
Then MsgBox("You clicked no!")
Else End If
End If
End Sub

feel free to ignore my ramblings...when vb changed to .net, I suddenly didn't feel like messing around with it anymore...so i haven't coded a VB app probably since prior to 2001...seriously.
 N3T_K1LLA

Joined: 11/20/2007
Msg: 4
VB help
Posted: 8/18/2009 9:16:54 PM
I'm having a problem with VB on msgboxresult. when i run this code it doesn't matter which button the user presses. yes or no. it still executes both statements when i only want it to execute the one the user chooses. both prompts come up... "you clicked no" and later "you clicked yes" and the test files get deleted either way. here is the code. if anyone knows how to fix this please help thanks

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
MsgBox("Are you sure you want to permanently delete these files?", MsgBoxStyle.YesNo)
If MsgBoxResult.No Then
MsgBox("you clicked no!")
End If
If MsgBoxResult.Yes Then
MsgBox("You clicked yes!")
End If
End Sub


You have two problems here.

1) You have not defined MsgBoxResult as a return value.
2) You are using two if statements instead of using else or elseif.

You'll need to format this properly in your source as it won't be indented correctly here.


Dim Answer as MsgBoxResult = MsgBox("Are you sure you want to permanently delete these files?", MsgBoxStyle.YesNo)
Select Case Answer
Case MsgBoxResult.Yes
MsgBox("you chose yes")
Case MsgBoxResult.No
MsgBox("you chose no")
Case Else
MsgBox("you chose something else unexpected") 'could mean they hit the X on the popup. You can always remove this.
End Select

Goodluck!
 airhead25

Joined: 5/7/2009
Msg: 5
view profile
History
VB help
Posted: 8/20/2009 6:40:04 PM
YAY! Awesome Thanks guys!
I love this stuff! programming is such much fun.

Page 1 of 1
 
Show ALL Forums  > Technology/Computers  > VB help