高手帮我将此段VB程序翻译成C语言
小弟乃VB菜鸟,只学过C语言。不懂,尤其是VB的运算符,很头疼。下面是代码
Public Function crc16z(ByVal txt As String, ByVal lon As Long) As Long
Dim flag As Long
Dim crc As Long
Dim car As Integer
Dim bit As Integer
Dim test As String
crc = &HFFFF&
For car = 1 To lon Step 2
crc = crc Xor getHex(Mid(txt, car, 2))
For bit = 0 To 7
flag = crc And 1&
crc = crc \ 2&
If flag = 1 Then crc = crc Xor &HA001&
Next
Next
crc16z = Int(crc And &HFFFF&)
End Function
Public Function getHex(ByVal inputString) As Byte
Dim ib As String
Dim returnValue
returnValue = 0
ib = UCase(Mid(inputString, 1, 1))
If ib = "0" Then returnValue = 0
If ib = "1" Then returnValue = 16
If ib = "2" Then returnValue = 32
If ib = "3" Then returnValue = 48
If ib = "4" Then returnValue = 64
If ib = "5" Then returnValue = 80
If ib = "6" Then returnValue = 96
If ib = "7" Then returnValue = 112
If ib = "8" Then returnValue = 128
If ib = "9" Then returnValue = 144
If ib = "A" Then returnValue = 160
If ib = "B" Then returnValue = 176
If ib = "C" Then returnValue = 192
If ib = "D" Then returnValue = 208
If ib = "E" Then returnValue = 224
If ib = "F" Then returnValue = 240
ib = UCase(Mid(inputString, 2, 1))
If ib = "0" Then returnValue = returnValue + 0
If ib = "1" Then returnValue = returnValue + 1
If ib = "2" Then returnValue = returnValue + 2
If ib = "3" Then returnValue = returnValue + 3
If ib = "4" Then returnValue = returnValue + 4
If ib = "5" Then returnValue = returnValue + 5
If ib = "6" Then returnValue = returnValue + 6
If ib = "7" Then returnValue = returnValue + 7
If ib = "8" Then returnValue = returnValue + 8
If ib = "9" Then returnValue = returnValue + 9
If ib = "A" Then returnValue = returnValue + 10
If ib = "B" Then returnValue = returnValue + 11
If ib = "C" Then returnValue = returnValue + 12
If ib = "D" Then returnValue = returnValue + 13
If ib = "E" Then returnValue = returnValue + 14
If ib = "F" Then returnValue = returnValue + 15
getHex = returnValue
End Function
...全文
相关推荐
C语言与VB语言的差别
### C语言与VB语言的差别#### 一、基本知识- **VB**:是一种面向对象的编程语言,主要用于Windows平台上的应用程序开发。
VB,C语言函数和程序例子
在编程世界中,Visual Basic(VB)和C语言是两种非常重要的编程语言,它们各自有着独特的特性和用途。本文将深入探讨VB和C语言中的函数和程序实例,帮助你更好地理解和掌握这两种语言。
可以在vb中程序中加入C语言代码的程序代码
很轻松的可以在vb中程序中加入C语言代码的程序,对混合语言开发很有帮助的
VB和C语言程序间交换数据的方法探讨.pdf
VB程序调用由C语言编写的可执行程序,并将硬盘上的文件路径作为参数传递给该程序。3. C语言程序启动后,读取VB程序写入的数据文件,进行必要的计算和数据处理。4.
谭浩强C语言全书VB版
《谭浩强C语言全书VB版》是针对经典编程教材《谭浩强C语言程序设计》进行改编的版本,旨在使读者在学习C语言的过程中,能够更好地利用Visual Basic(VB)这一流行的编程环境进行实践操作和理解。


VB基础类
