以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- HexToDec未声明名称的处理 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=147513) |
-- 作者:wangjh8888 -- 发布时间:2020/3/18 14:22:00 -- HexToDec未声明名称的处理 老师 好 Dim s As String = "7b" Dim d As Integer =HexToDec(s) 上面代码在命令窗口可以执行,在全局代码就提示HexToDec未声明名称,怎么办? |
-- 作者:有点蓝 -- 发布时间:2020/3/18 14:25:00 -- 这个不支持全局代码,放到函数里,然后在全局代码调用函数 |
-- 作者:wangjh8888 -- 发布时间:2020/3/18 14:52:00 -- 老师 是不是在内部函数 增加这个函数吗 ( HexToDec ) |
-- 作者:有点蓝 -- 发布时间:2020/3/18 14:59:00 -- 添加一个内部函数,把全局代码的用法搬到函数里 |
-- 作者:wangjh8888 -- 发布时间:2020/3/18 15:07:00 -- 老师, 内部函数还不会使用,教教我。以下是我要的函数,应该怎么写在内部函数? 谢谢 Public Function Make_我要的GPS数据(GPSstr As String) As Boolean Dim result As Boolean Dim S As String = GPSstr.trim() Dim n1 As Integer = S.IndexOf("$")+1 Dim n2 As Integer = S.LastIndexOf("*")-1 Dim SR As String = S.SubString(S.LastIndexOf("*")+1) S = S.SubString(n1,n2-n1+1) Dim cs(s.length-1) As String For i As Integer = 0 To s.length-1 cs(i) = S.SubString(i,1) Next Dim RR As Integer = ASC(cs(0)) For i As Integer = 1 To s.length-1 RR=RR xor ASC(cs(i)) Next If RR = HexToDec(SR) Then result =True Else result =False End If Return result End Function
|
-- 作者:有点蓝 -- 发布时间:2020/3/18 15:28:00 -- 添加一个函数,比如名称abc,代码 dim GPSstr As String = arg(0) Dim result As Boolean Dim S As String = GPSstr.trim() Dim n1 As Integer = S.IndexOf("$")+1 Dim n2 As Integer = S.LastIndexOf("*")-1 Dim SR As String = S.SubString(S.LastIndexOf("*")+1) S = S.SubString(n1,n2-n1+1) Dim cs(s.length-1) As String For i As Integer = 0 To s.length-1 cs(i) = S.SubString(i,1) Next Dim RR As Integer = ASC(cs(0)) For i As Integer = 1 To s.length-1 RR=RR xor ASC(cs(i)) Next If RR = HexToDec(SR) Then result =True Else result =False End If Return result 全局代码: Public Function Make_我要的GPS数据(GPSstr As String) As Boolean Functions.Execute(“abc”,GPSstr ) end Function
|
-- 作者:wangjh8888 -- 发布时间:2020/3/18 17:44:00 -- 老师 下面代码,校验通过时,出错提示啊,快帮看看问题在哪里啊,谢谢,谢谢 内部函数:GPS校验 Dim GPSstr As String = args(0) Dim result As Boolean Dim S As String = GPSstr.trim() Dim n1 As Integer = S.IndexOf("$")+1 Dim n2 As Integer = S.LastIndexOf("*")-1 Dim SR As String = S.SubString(S.LastIndexOf("*")+1) S = S.SubString(n1,n2-n1+1) Dim cs(s.length-1) As String For i As Integer = 0 To s.length-1 cs(i) = S.SubString(i,1) Next Dim RR As Integer = ASC(cs(0)) For i As Integer = 1 To s.length-1 RR=RR xor ASC(cs(i)) Next If RR = HexToDec(SR) Then result =True Else result =False End If Return result 全局代码: Public datetime_GPRMC As Date Public jd_GPRMC As Double Public jb_GPRMC As String Public wd_GPRMC As Double Public wb_GPRMC As String Public Function Make_我要的GPS数据(GPSstr As String) As Boolean Dim result As Boolean= Functions.Execute("GPS校验",GPSstr) If result Then Dim cs() As String = GPSstr.Trim().Split(",") \'\'每列 *** rs(i).Trim(). \'\' ------------------ Longdatetimestr 2020-03-13 09:54:46 Dim yyyy As String ="20" & cs(9).SubString(4,2) Dim yy As String =cs(9).SubString(2,2) Dim dd As String =cs(9).SubString(0,2) Dim hh As String =cs(1).SubString(0,2) Dim mm As String =cs(1).SubString(2,2) Dim ss As String =cs(1).SubString(4) datetime_GPRMC = Cdate(yyyy & "-" & yy & "-" & dd & " " & hh & ":" & mm & ":" & ss) \'\' ------------------ jd 118.1085966666 24.4887866666 jd_GPRMC = GPSStrToVal(cs(5).trim()) jb_GPRMC = cs(6).trim() wd_GPRMC = GPSStrToVal(cs(3).trim()) wb_GPRMC = cs(4).trim() End If Return result End Function 命令窗口: Dim GPSstr As String ="$GPVTG,89.68,T,,M,0.00,N,0.0,K*5F" Dim b As Boolean =Make_我要的GPS数据(GPSstr) msgbox(b) 不好意思 找到问题了 我的错误,打搅了!! [此贴子已经被作者于2020/3/18 17:51:38编辑过]
|