客户端向服务器端发送一个string类型字符串时
str = "yidong" & "," & CStr(x1) & "," & CStr(X2)
服务器收到后做怎样的处理才能得到字符串"yidong"和整形变量 x,y
也就是怎么样将上面的函数分开
不知道用什么函数?
vb又没有指针,不知道怎么样实现
请指点
谢谢
Private Sub Form_Load()
Dim X As Long, Y As Long, STR2 As String, STR1 As String, X1 As Long, Y1 As Long
'以下只是为了演示调用GetSTRS函数
X1 = 100
X2 = 6000
STR1 = "yidong" & "," & CStr(X1) & "," & CStr(X2)
If Not GetSTRS(STR1, STR2, X, Y) Then
MsgBox "字符串的组数不正确!"
Else
Me.Print STR2
Me.Print X
Me.Print Y
Print
End If
End Sub
Private Function GetSTRS(ByVal STR1 As String, ByRef STR2 As String, ByRef X As Long, ByRef Y As Long) As Boolean
'定义成函数是为了方便调用,如果成功拆分返回True.
STRS = Split(STR1, ",")
If UBound(STRS) <> 2 Then Exit Function
X = CLng(STRS(1))
Y = CLng(STRS(2))
STR2 = STRS(0)
GetSTRS = True
End Function
[此贴子已经被作者于2007-4-11 12:56:00编辑过]
我做的是基于web的地理信息系统
实现图片拖动后,服务器把处理后的图片发过来
客户端
Public x1 As Long
Public y1 As Long
Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
x1 = X
y1 = Y
End Sub
Private Sub Picture2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
x1 = X - x1
y1 = Y - y1
End Sub
Private Sub yidong_Click()
Dim str As String
Sleep 1000 //等待 x1,y1赋值
str = "yidong" & "," & CStr(x1) & "," & CStr(X2)
wskb.SendData str
End Sub
服务器端
Dim str As String
Dim X As Long
Dim Y As Long
Wska.GetData str
strb = Split(str, ",")
If strb(0) Like "yidong" Then
str = strb(0)
X = CLng(strb(1))
Y = CLng(strb(2)) '这块提示类型不匹配
Map1.CenterX = Map1.CenterX + X
Map1.CenterY = Map1.CenterY + Y
end if
大家帮忙看一下 错误在哪儿?