永发信息网

如何根据VB的GetData收到的数据进行判断

答案:1  悬赏:20  手机版
解决时间 2021-03-21 11:39
  • 提问者网友:情歌越听越心酸
  • 2021-03-21 02:44
我在写一个与telnet交互的程序,自动输入用户名和密码,然后根据收到的数据进行判断。

代码如下:
Private Sub winsock1_DataArrival(ByVal bytesTotal As Long)
Dim arrival() As Byte, i As Long, s As String, dat As String
ReDim arrival(bytesTotal - 1) As Byte

s = ""
dat = ""

Winsock1.GetData arrival, vbByte, bytesTotal
For i = 0 To bytesTotal - 1
s = s & bytesTotal & "arrival" & i & "," & arrival(i) & vbCrLf '看从服务器接收到的数据,转换成十进制
If (bytesTotal = 18) And i = 17 And arrival(i) = 32 Then
Winsock1.SendData "admin" & vbCrLf '输入用户名
Winsock1.SendData "password" & vbCrLf '输入密码
End If

Text2.Text = StrConv(arrival, vbUnicode) & vbCrLf

Next
Text1.Text = s
End Sub

我现在的问题是,不知道在哪里加入一个判断语句说:
收到的第n个值是13, n+1的值是10,n+2的值是13,n+3的值是13,n+4的值是10,那么msgbobox ("登录成功")。这个只要判断一次就可以了。

然后输入指令,再根据接收到的数据进一步判断。

请大家帮我看一下,应该怎么改。谢谢。
最佳答案
  • 五星知识达人网友:污到你湿
  • 2021-03-21 03:53
Dim dlcg As Boolean

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim arrival() As Byte, i As Long, s As String, dat As String, strMask As String

ReDim arrival(bytesTotal - 1) As Byte

s = ""
dat = ""

If dlcg = True Then
Winsock1.GetData s
Else

Winsock1.GetData arrival, vbByte, bytesTotal

For i = 0 To bytesTotal - 1
s = s & bytesTotal & "arrival" & i & "," & arrival(i) & vbCrLf
'Text2.Text = dat & StrConv(arrival, vbUnicode) & vbCrLf

If (bytesTotal = 18) And i = 17 And arrival(i) = 32 Then
Winsock1.SendData "admin" & vbCrLf 'username
DoEvents

Winsock1.SendData "password" & vbCrLf 'password
DoEvents

End If

'Text2.Text = StrConv(arrival, vbUnicode) & vbCrLf

Next
End If

Text1.Text = s
Text2.Text = StrConv(arrival, vbUnicode) & vbCrLf
MsgBox (bytesTotal & StrConv(arrival, vbUnicode))

If 登录成功 Then
dlcg = True
End If
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯