Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Winsock Help 1

Status
Not open for further replies.

UKmedia

Programmer
Nov 2, 2002
90
0
0
Hey All,

I have an application that is receiving a reponse from another program. The program sends it's response as:

1=9
0=999

Now the reponse is not always the same and I want to use a select case to read the reponse.

Code:
Dim strReceive
Winsock1.GetData strReceive
txtReceive.Text = strReceive

Select Case

Case strReceive

Case ""
lblResponse.Caption = "Good"

Case ""
lblResponse.Caption = "Bad"

Case ""
lblResponse.Caption = "Complete"

Case Else 
        lblResponse.Caption = "Unknown Response" 

End Select

Now I know what all the reponse codes are but in the Case "" if I put Case "3=999=0" it will not work as the data coming in is on 2 lines.

How can i split the data going in and show this inb each case.

Cheers

UKmedia productions
 
nope my code did not get it to work.

How can I read the whole of strResponse and just look through the string for 3=status of card

as looking at the responses the 3= is always coming in at a different place?

UKmedia productions
 
'build example string
Dim strReceive As String
strReceive = "3=99" & vbLf & "7=1111111111" & vbLf & "29=A00000000313131" & vbLf & "6=Mastercard" & vbLf & "10=UKMedia"

MsgBox Filter(Split(strReceive, vbLf), "3=")(0)
 
Option Explicit

Private Sub Command1_Click()

Dim strResponse As String
Dim FirstPart As String
Dim LastPart As String
Dim tempArray() As String

strResponse = "123=456"

tempArray = Split(strResponse, "=")
FirstPart = tempArray(0)
LastPart = tempArray(1)

Print FirstPart
Print LastPart

End Sub
 
getting there lol,

there is a line in there which is

23=Demo Merchant

so it is picking up that then just the 3=

how can I tell it just to get the 3= and not anything else like 23= Demo Merchant

the problem is the 3= is always on different lines too so I cannot just tell it to split the data into rows and then just look at row say 13.

??

UKmedia productions
 
See, now you know why it is important to provide all the specifications of a problem :)

I'd be tempted to move to regular expressions for this now:

Dim varresult As Object

'build example string
Dim strReceive As String
strReceive = "7=1111111111" & vbLf & "23=Mastercard" & vbLf & "29=A00000000313131" & vbLf & "3=99" & vbLf & "10=UKMedia"


With CreateObject("vbscript.regexp")
.Pattern = "^3=.*"
.MultiLine = True
For Each varresult In .Execute(strReceive)
MsgBox varresult
Next
End With


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top