Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 ASCII Converter
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
peterggmss




PostPosted: Thu Dec 14, 2006 1:52 pm   Post subject: ASCII Converter

When I enter something like "you suck" i get 121 for y but also 121 for s. I have attached an EXE so that you can try it.

code:
    Dim UserInput, Action
    Dim Length, LengthDone
    Dim Output
    Dim NewInput As String
   
Private Sub cmdConvert_Click()
   
    'What should we do with the input?
    If optEncode.Enabled = False And optDecode.Enabled = False Then
        MsgBox ("Select an action to perform")
        Exit Sub
    End If
    If optEncode.Enabled = True Then
        Action = Encode
    End If
    If optDecode.Enabled = True Then
        Action = Decode
    End If
   
    'What is the input?
    UserInput = txtInput.Text

    'How long is the input?
    Length = Len(UserInput)
   
    'We should tell the user what they gave us
    lblInput.Caption = UserInput
   
    txtInput.Text = ""
    LengthDone = 1
    'Calculate the ASCII Values
    If Action = Encode Then
        'For Length = 1 To Length COMMENTED OUT - WILL NOT EXECUTE
        Do Until LengthDone = Length
            Output = Asc(Left(UserInput, LengthDone)) '+ " "
            NewInput = NewInput + Str(Output) '+ " "
            LengthDone = LengthDone + 1
        'Next COMMENTED OUT - WILL NOT EXECUTE
        Loop
    End If
               
    'Calculate the text values
    If Action = Decode Then
        Do Until LengthDone = Length
            Output = Chr(Left(UserInput, LengthDone))
            NewInput = NewInput + Output
            LengthDone = LengthDone + 1
        Loop
    End If
       
    'Lets show them the output
    txtInput.Text = NewInput
                   
   'lblInput.Caption = txtInput.Text
   'txtInput.Text = Asc(txtInput.Text)

End Sub



The Extension 'exe' was deactivated by an board admin, therefore this Attachment is not displayed.

Sponsor
Sponsor
Sponsor
sponsor
Silent Avenger




PostPosted: Thu Dec 14, 2006 7:18 pm   Post subject: (No subject)

Are you trying to get each ASCII code for each letter of what the user typed in?
cool dude




PostPosted: Thu Dec 14, 2006 7:35 pm   Post subject: (No subject)

i'm not exactly sure of what your trying to do and i am not going to download the exe unless you provide the actual form. (i don't like exe)
however this might help you. basically you press any key and on your form it will show you the ascii value of that key.

code:

Private Sub Form_KeyPress(KeyAscii As Integer)
    Print KeyAscii
End Sub
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: