?
Solved

wsTCP.SendData does not send Chr(13) as Carriage Return

Posted on 2010-08-17
5
Medium Priority
?
550 Views
Last Modified: 2012-05-10
Sending Chr(13) is supposed to be equivalent to pressing 'Enter' on the keyboard. However, the program thinks that I am trying to send the string "Chr(13)". How can I go about this problem? Thanks.
Private Sub cmdLogin_Click()
    If Run.Value Then
        progctrfinal = TextBox1.Value
        For progctr = 1 To progctrfinal Step 1
            Call optionStatus(progctr)
        Next progctr
    End If
End Sub

Function CommandCode(PC As Long)
    Dim command As String
    Dim argPassedIn As String

    Debug.Print progctr
    command = Worksheets("GUI").Cells(PC + 1, 2).Value
    argPassedIn = Worksheets("GUI").Cells(PC + 1, 3).Value
    Debug.Print command & " " & (argPassedIn)
    If command = "MySend" Then Call MySend(argPassedIn)

End Function

Function MySend(ByVal data As String)
    DoEvents
    wsTCP.SendData data
End Function

Private Sub optionStatus(ByVal progctr As Long)
    Select Case progctr
        Case 1      
            Login
            Call WaitCurs(20, 51)
            If Not CurPos Then Exit Sub
            
        Case 2
            Call CommandCode(progctr)
          
        Case 3
            CommandCode progctr
'
        Case 4
            CommandCode progctr
            
        Case 5
            Debug.Print "Case 5"
            CommandCode progctr
        
        Case Else
            Debug.Print "No match"
            'Code for any nonmatch
    End Select
End Sub

Open in new window

main-menu.JPG
0
Comment
Question by:teeling
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 2000 total points
ID: 33461468
Is data the string "Chr(13)"? If so, that will be why.

Try

Function MySend(ByVal data As String)
    DoEvents
    If LCase(data)="chr(13)" Then data = Chr(13)
    wsTCP.SendData data
End Function

or some sort of replace if the string can contain other chars + chr(13)
0
 

Author Comment

by:teeling
ID: 33461526
I am not sure whether it's sending the 'Enter' key because it's coming up with some error prompt in the excel sheet.

If I were to do this manually, pressing enter sends me straight to another menu.

Thanks.
Selection-0.JPG
0
 

Author Comment

by:teeling
ID: 33461648
I found out what's the problem. I have sent an extra sets of "". Thanks for the help :)
0
 

Author Closing Comment

by:teeling
ID: 33461650
Prompt reply.
0
 

Author Comment

by:teeling
ID: 33461668
Another related question, what if I'm trying to send the key F1, which is a combination of several characters, i.e. Chr(27) & "O" & "P"?
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question