Help with randomizer please.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jackovb
    New Member
    • Feb 2007
    • 1

    #1

    Help with randomizer please.

    Code:
            Dim A As Integer
            Dim B As Integer
            B = 0
    
            Dim LArray() As String = {"a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z"}
            Dim SArray() As String = {"`, ~, !, @, #, $, %, ^, &, *, (, ), [, {, ], }, \, |, ;, :, ', /, ?, ., >, <"}
            Dim LSArray() As String = {"a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z,`,~,!,@,#,$,%,^,&,*,(,),[,{,],},\,|,;,:,',/,?,.,>,<"}
            If letterbox.Checked = True Then A = B + 1
            end if
            If symbolbox.Checked = True Then A = B + 10
            end if
            If A = 1 Then TextBox3.Text = LArray(Int(Rnd() * 25))
            end if
            If A = 10 Then TextBox3.Text = SArray(Int(Rnd() * 25))
            end if
            If A = 11 Then TextBox3.Text = LSArray(Int(Rnd() * 50))
            end if

    The End If is underlined and said it needs a preceding 'If'

    It does have one but for some reason it isn't recognizing it and I think I need brackets or parenthesis somewhere but I'm new to VB(thus the newb stuff) and I'm just making random stuff to help me learn it.

    And for those wondering, it randomly generates a letter, a symbol, or a letter/symbol.

    Please Help, Jack-O-VB
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Not quite. An IF statement can be constructed in two ways. The single-line version is simply
    Code:
    If Condition Then DoSomething
    The multi-line version is
    Code:
    If Condition Then
      DoSomething
      ...
    End If
    In your case you need to either remove the End If, or split the "DoSomethin g" code onto a separate line. the choice is yours.

    Side note: in checking multiple values of A in that way, you should check out the Select Case statement.

    Comment

    Working...