Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-07-2004, 08:11 PM   #1
Member (1 bit)
 
Join Date: Mar 2004
Posts: 1
Thumbs up Visual Basic - Message Boxes

i'm doin a simple program but i'm trying to figure out this message box stuff.....

i have a variable called intSum that is total of all the rolls of the dice (yes, it's the lame dice game). i want to display a message box that says 'you lose' as the title bar and 'your score is ##' for the body of the message box. i can only get it to display only the variable if i only includ ethe variable and nothing else. ... e.g. msgbox (intSum, , "You Lose")

i was going to make another form as a message box with the yes, no buttons asking if you wanna play another game, AND showing the score (intSum), but i KNOW there's an easy way to do it with a msgbox. any help??? THANKS!!!!!!





Option Explicit
Dim intRolls(29) As Integer
dim intRollNum As Integer
dim intCounter As Integer
dim intsum As Integer

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdHelp_Click()
frmDiceGame.Hide
frmHelp.Show
End Sub

Private Sub cmdRoll_Click()
Dim intDie As Integer, intForCount As Integer
Dim intResults As Integer

intCounter = intCounter + 1

If intCounter < 29 Then

Randomize 'Simulate roll of die
intDie = Int((6 * Rnd) + 1)

intRollNum = intRollNum + 1
intRolls(intRollNum) = intDie

lstRolls.AddItem "Roll #" & intRollNum & _
": " & intRolls(intRollNum)

intsum = intDie + intsum

If intsum > 29 Then
lstTotal.Clear
lstTotal.AddItem intsum
intResults = MsgBox _
("Do you want to play again?", vbYesNo, "You Lose")
lstRolls.Clear
lstTotal.Clear

If intResults = 6 Then 'Start another game
intCounter = 0
intsum = 0
intRollNum = 0
Else
End
End If

Else

lstTotal.Clear
lstTotal.AddItem intsum

End If
Else
MsgBox ("You may not roll again")
Exit Sub
End If

Debug.Print intRolls(intCounter)

End Sub

Private Sub cmdStop_Click()
Dim intResults As Integer

If intsum < 26 Then
intResults = MsgBox("You can't stop now!", , "Keep Playing")
Exit Sub
Else
intResults = MsgBox(intsum, vbYesNo, "Play again?")

If intResults = 6 Then
intCounter = 0
intsum = 0
intRollNum = 0
lstTotal.Clear
lstRolls.Clear
Else
End
End If

End If


End Sub
alkalinemo is offline   Reply With Quote
Old 03-08-2004, 12:14 PM   #2
Member (7 bit)
 
Zick Boy's Avatar
 
Join Date: Feb 2004
Location: Owings Mills, MD
Posts: 95
MsgBox ("Your score is " & intSum, ,"You Lose")
Zick Boy is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:48 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2