Dim strMess As String
dim a as long
strMess = "abcdef"
a=strmess
Call ShowStr(a)
......Public Sub ShowStr(lTest As Long)
dim b as string
b=lTest
MsgBox b
End Sub
dim a as long
strMess = "abcdef"
a=strmess
Call ShowStr(a)
......Public Sub ShowStr(lTest As Long)
dim b as string
b=lTest
MsgBox b
End Sub
-----------
Dim strMess As String
dim a as long
strMess = "abcdef"
a=getMesID(strMess)
Call ShowStr(a)
......public function getMesID(byval sMes as string) as long
col.add sMes
getMesID=col.count
end function
Public Sub ShowStr(lTest As Long)
dim b as string
b=col(lTest)
MsgBox b
End Sub
要么就用DeD(似水年华)的方法,用Collection来保存信息,这是传递的lTest其实是索引,而不是内容.
顺便问一句,为什么有这样的要求呢?
我通过转换后,可以实现3个字符的传递,并且只有当字符串中无汉字才行。
程序如下:
Public Sub ShowStr(lTest As Long)
Dim strOld As String
Dim strTest As String
Dim strTmp As String
Dim i As Integer
strTest = CStr(lTest)
If Val(Left$(strTest, 1)) > 3 Then strTest = "0" + strTest
For i = 1 To Len(strTest) Step 3 '将Ascii码还原成字符
strTmp = Chr(Mid(strTest, i, 3))
strOld = strOld + strTmp
Next i
MsgBox strOld
End SubPrivate Sub Form_Load()
Dim strMess As String
strMess = "abc"
ShowStr str2lng(strMess)
End
End SubPublic Function str2lng(ByVal strSour As String) As Long
Dim i As Integer
Dim sAscii As String
Dim sResult As String
For i = 1 To Len(strSour) '将字符转换成对应的Ascii码
sAscii = Format$(Asc(Mid$(strSour, i, 1)), "0##")
sResult = sResult + sAscii
Next i
str2lng = CLng(sResult)
End Function
我已经叫朋友考虑用别的办法了(他好象需要在程序中投递消息到另一个程序)
谢谢各位。