3 Replies - 892 Views - Last Post: 01 May 2009 - 05:49 PM Rate Topic: -----

#1 biggles2008  Icon User is offline

  • Bassface
  • member icon

Reputation: 9
  • View blog
  • Posts: 623
  • Joined: 05-March 08

Randomly Generating Characters

Posted 30 April 2009 - 04:02 PM

Hi

I'm creating a mathematics program to help me get better at it :P
I want to randomly generate an operator so it Adds, Subtracts, Multiplies or Divides depending on what checkbox the user has selected...obviously if the user selects just one e.g. Addition, only the addition operator will be generated but if multiple operations have been selected it will randomize between operators.

The reason i am creating this is to increase my mental arithmetic skills, as it will randomly generate numbers, operators and i have a time limit to answer the question in.
The answer will be shown after the time limit is up or the user clicks "Show Answer".

But for now i only need help generating the operators.
Any help will be much appreciated.

The interface "X" is where the random operator goes.
Attached Image

Dim num1 As Integer
Dim num2 As Integer
Dim add As Integer
Dim sut As Integer
Dim mul As Integer
Dim div As Integer



Private Sub cmdAll_Click()
chkAdd.Value = 1
chkSub.Value = 1
chkMul.Value = 1
chkDiv.Value = 1
End Sub

Private Sub cmdNew_Click()
'operators
add = "+"
sut = "-"
mul = "*"
div = "/"
 
 'I have no idea guys
Random = (Rnd(add, sut, mul, div))





If chkAdd.Value = 1 Then
lblSign = "+"
End If
If chkSub.Value = 1 Then
lblSign = "-"
End If
If chkMul.Value = 1 Then
lblSign = "*"
End If
If chkDiv.Value = 1 Then
lblSign = "/"
End If

End Sub




Is This A Good Question/Topic? 0
  • +

Replies To: Randomly Generating Characters

#2 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 91
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: Randomly Generating Characters

Posted 30 April 2009 - 05:02 PM

This code can randomly generate maths symbols.
Private Sub Command1_Click()
Dim add As String
Dim sut As String
Dim div As String
Dim mul As String
Dim str As String
Dim ran(4) As String

add = "+"
sut = "-"
div = "/"
mul = "*"

ran(1) = add
ran(2) = sut
ran(3) = div
ran(4) = mul

str = ran(Int(Rnd * 4 + 1))

Text1.Text = str
End Sub



Just say thanks :P

This post has been edited by firebolt: 30 April 2009 - 08:07 PM

Was This Post Helpful? 1
  • +
  • -

#3 biggles2008  Icon User is offline

  • Bassface
  • member icon

Reputation: 9
  • View blog
  • Posts: 623
  • Joined: 05-March 08

Re: Randomly Generating Characters

Posted 01 May 2009 - 06:56 AM

Thanks Firebolt works perfectly.
Was This Post Helpful? 0
  • +
  • -

#4 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 91
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: Randomly Generating Characters

Posted 01 May 2009 - 05:49 PM

Your welcome.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1