有个VB的列子,可以通过读取HZK16和ASC16这2个UCDOS下的文件,再通过MSCOMM控件写入LED显示屏,来显示点阵汉字,请问要如何修改到C#上使用呢?
Function CALL_LED(ledstring As String) As String
Dim zw(1 To 32) As Byte
Dim zc(1 To 32) As Byte
Dim zimo As Integer
For I = 1 To Len(ledstring) Step 1
If Asc(Mid$(ledstring, I, 1)) < 0 Then
'写入的是汉字
If zimo = 1 Then MSComLED.Output = zc: zimo = 0
AA = Hex(Asc(Mid(ledstring, I, 1)))
bb = (94 * (CLng("&H" & Mid(AA, 1, 2)) - &HA1) + (CLng("&H" & Mid(AA, 3, 2)) - &HA1)) * 32 + 1
HzFile = App.Path + "\" + "hzk16"
Open HzFile For Binary Access Read As #1 '读取该汉字在16*16点阵字库中的原始字模
Get #1, bb, zw
Close #1
MSComLED.Output = zw
Else
'写入的不是汉字
If zimo = 0 Then
AA = Hex(Asc(Mid(ledstring, I, 1)))
bb = (CLng("&H" & Mid(AA, 1, 2))) * 16 + 1
HzFile = App.Path + "\" + "ASC16"
Open HzFile For Binary Access Read As #2 '读取该汉字在8*16点阵字库中的原始字模
Get #2, bb, zw
Close #2
zc(1) = zw(1): zc(3) = zw(2): zc(5) = zw(3): zc(7) = zw(4): zc(9) = zw(5): zc(11) = zw(6)
zc(13) = zw(7): zc(15) = zw(8): zc(17) = zw(9): zc(19) = zw(10): zc(21) = zw(11): zc(23) = zw(12)
zc(25) = zw(13): zc(27) = zw(14): zc(29) = zw(15): zc(31) = zw(16): zimo = 1
zc(2) = 0: zc(4) = 0: zc(6) = 0: zc(8) = 0: zc(10) = 0: zc(12) = 0: zc(14) = 0: zc(16) = 0
zc(18) = 0: zc(20) = 0: zc(22) = 0: zc(24) = 0: zc(26) = 0: zc(28) = 0: zc(30) = 0: zc(32) = 0
Else
AA = Hex(Asc(Mid(ledstring, I, 1)))
bb = (CLng("&H" & Mid(AA, 1, 2))) * 16 + 1
HzFile = App.Path + "\" + "ASC16"
Open HzFile For Binary Access Read As #3 '读取该汉字在8*16点阵字库中的原始字模
Get #3, bb, zw
Close #3
zc(2) = zw(1): zc(4) = zw(2): zc(6) = zw(3): zc(8) = zw(4): zc(10) = zw(5): zc(12) = zw(6)
zc(14) = zw(7): zc(16) = zw(8): zc(18) = zw(9): zc(20) = zw(10): zc(22) = zw(11): zc(24) = zw(12)
zc(26) = zw(13): zc(28) = zw(14): zc(30) = zw(15): zc(32) = zw(16): zimo = 0
MSComLED.Output = zc
End If
End If
Next
If zimo = 1 Then MSComLED.Output = zc: zimo = 0
End Function