Results 1 to 5 of 5

Thread: Code Problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    154

    Code Problem

    Well this is my code below. What the point of it is is to create a random code and display it in text1.
    VB Code:
    1. Public Sub Command1_Click()
    2.     Text1.Text = Mixup
    3. End Sub
    4.  
    5. Function Mixup () As String
    6. Dim x as Integer
    7. Dim chooser as Integer
    8.  
    9. For x = 0 to 7
    10.  
    11. [B]chooser = Int((3 * Rnd) + 1))
    12.  
    13. case select chooser[/B]
    14.    case 1
    15.        str = str + Chr(Int((122 * Rnd) + 90)) ' for lower case
    16.    case 2
    17.        str = str + Chr(Int(( 90* Rnd) + 65)) ' for upper case
    18.    case 3
    19.        str = str + Chr(Int((9 * Rnd) + 0)) ' for 0-9 case
    20. [B]end case[/B]
    21.  
    22. Next
    23.  
    24.     Mixup = str
    25.  
    26. End Function

    This is my code and the things in bold are red in vb which means theres a problem but dont know how to fix them...So any help and advice on how to fix this would be very much appreciated thx guys

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    1 too many parenthesis.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    154
    Originally posted by Cander
    1 too many parenthesis.
    Which one shouldnt be there?Thx for the help man

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    farthest right one.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Besides the parenthesis error, you also have the syntax of the Case statement wrong. It should be

    VB Code:
    1. [b]select case [/b]chooser
    2.    case 1
    3.        str = str + Chr(Int((122 * Rnd) + 90)) ' for lower case
    4.    case 2
    5.        str = str + Chr(Int(( 90* Rnd) + 65)) ' for upper case
    6.    case 3
    7.        str = str + Chr(Int((9 * Rnd) + 0)) ' for 0-9 case
    8. end case

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width