SmallBasic Random Math Help!

• Question

• Hi,

I am new to Small Basic and I am trying to make something give random math questions and you guess them. The only problem is I can't figure out how to make it when you type A it goes to Addition and when you type M it goes to Multiplication

```TextWindow.WriteLine("For Addition Type (A) for Multiplcation Type (M)")

Input = Controls.LastTypedTextBox
A = Input
M = Input

If Input = A Then
TextWindow.WriteLine("Guess the math question")

M1 = Math.GetRandomNumber(10)
M2 = Math.GetRandomNumber(10)

TextWindow.WriteLine(M1 + " + " + M2 + " =")

ANS= M1+M2

If M1>M2 Then
Else
EndIf
If Input = M Then
TextWindow.WriteLine("Guess the math question")

M3 = Math.GetRandomNumber(10)
M4 = Math.GetRandomNumber(10)

TextWindow.WriteLine(M3 + " * " + M4 + " =")

ANS= M3*M4

If M1>M2 Then
Else
EndIf
EndIf
Else
TextWindow.WriteLine("Input Not Recognized")
EndIf```

Wednesday, January 25, 2017 7:49 AM

• Forbidden Duck,

Here's your program that now works. I tried to do minimal changes so that you can compare this to your original program. Some enhancement suggestions.

1. Have it check for upper and lower case A and M

2. Have the program go back to the beginning so you don't have to restart it each time.

TextWindow.WriteLine("For Addition Type (A) for Multiplcation Type (M)")
'Input = Controls.LastTypedTextBox
'A = Input
'M = Input
If Inputtext = "A" Then
TextWindow.WriteLine("Guess the math question")
M1 = Math.GetRandomNumber(10)
M2 = Math.GetRandomNumber(10)
TextWindow.WriteLine(M1 + " + " + M2 + " =")
ANS= M1+M2
If User = ANS Then
Else
EndIf
elseif Inputtext = "M" Then
TextWindow.WriteLine("Here")
TextWindow.WriteLine("Guess the math question")
M3 = Math.GetRandomNumber(10)
M4 = Math.GetRandomNumber(10)
TextWindow.WriteLine(M3 + " * " + M4 + " =")
ANS= M3*M4
If User=ANS Then