Add from one label to another label!!!!!!!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • THEAF
    New Member
    • Mar 2007
    • 52

    Add from one label to another label!!!!!!!!!

    hi,
    i'm tryin to create this math questions form for my sister. the form has 2 labels where random numbers show, a text box where the answer is entered, a next button the next numbers and an exit button.

    This is my next button and my random number generator.
    Private Sub Command2_Click( )
    '
    If Val(lbl1) * Val(lbl2) = txta.Text Then 'txta.text is the textbox were the answer is entered
    txta.Text = ""
    Random
    lblQno.Caption = Val(lblQno.Capt ion) + 1 ' label showa how many questions answered

    ElseIf Not Val(lbl1) * Val(lbl2) = txta.Text Then
    txta.Text = ""
    Random
    lblQno.Caption = Val(lblQno.Capt ion) + 1
    End If
    End Sub

    Public Sub Random()
    Randomize
    lbl1 = Int(Rnd * 13)
    lbl2 = Int(Rnd * 13)
    End Sub

    what i want is that when the question is answered the numbers on lbl1 and lbl2 should then be in caption in 2 other labels on another form. this should happen even if the answer is wrong. i'm thinkin that it may be some array or something but i'm not sure. Could anyone please help me solve this problem & if there is anything i need to further explain then please tell me. THANK YOU
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    What version of vb is this?

    if you want to generate a random number better to use something like...

    [code=text]
    Dim b As Integer = System.DateTime .Now.Millisecon d
    [/code]

    Comment

    • kadghar
      Recognized Expert Top Contributor
      • Apr 2007
      • 1302

      #3
      hmmm

      Using Randomize will change the seed, using the miliseconds of the time, so it's even a better and easier method, but there's no need to use it each time you generate numbers, if you use it only once, at the beginig, its good enough.

      to write something in another form, remember the controls of a form are also its children. so you can do:

      [CODE=vb]Form2.label1.ca ption = me.label1.capti on[/CODE]

      or use the controls list:

      [CODE=vb]form2.controls( "label1").capti on = me.label1.capti on[/CODE]

      This should work for some versions, but if it doesnt, it'll help if you tell us the version of VB you're using.

      by the way, there's no need of using ElseIf Not(..) in this very case, something like this should do
      [CODE=vb]
      if a*b = txt1.text then
      'whatever it does when its right
      else
      'whatever it does when its wrong.
      end if[/CODE]

      HTH

      Comment

      Working...