Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Roll The Dice InputBox$ and MessageBox Example
#1
Recently QB64pe added the InputBox$ and MessageBox popups, so today I decided to have some fun with it and make a dice roller. The first popup asks how many sides your dice is, from 3 to 100. Then it rolls and another popup says the outcome. I know this is very primary random stuff, but I thought it would be a good example for the popups. 
This is also the first time I've used both the input and the message boxes in one QB64pe app. Smile Years ago, when I tried out someone's GUI framework for QB64, I made a very similar dice roller with forms and buttons. I wonder if that GUI from back then still works? 

Anyway, here you go, enjoy. Smile 

Code: (Select All)

_Title "Roll The Dice by SierraKen"
Randomize Timer
Do
    Do
        title$ = "Roll The Dice"
        defaultInput$ = " "
        message$ = "How many sides is your dice (3-100)?"
        result$ = _InputBox$(title$, message$, defaultInput$)
        If _Trim$(result$) = "" Then End
        num = Val(result$)
        If num < 3 Or num > 100 Or num <> Int(num) Then
            _MessageBox "Roll The Dice", "Pick only between 3 and 100."
            Exit Do
        End If
        dice = Int(Rnd * num) + 1
        dice$ = Str$(dice)
        _MessageBox "Roll The Dice", "Your roll: " + dice$
    Loop
Loop
Reply


Messages In This Thread
Roll The Dice InputBox$ and MessageBox Example - by SierraKen - 02-15-2025, 11:58 PM



Users browsing this thread: 9 Guest(s)