誰かがこれに頭を悩ませることができますか?16進バイトに2バイトがあり、値が0〜9とAFの間にあることを確認するだけだと思っていましたが、そうではありませんでした。
赤外線コントローラー/ブラスター用のプログラムの断片。このサブルーチンは、実際の信号 (またはその他のコード) をシリアル ポートからコントローラーに送信して、ジョブを完了させます。
呼び出しの例:
SendCode ("04241001")
VB6コードは次のように述べています:
Public Sub SendCode(ByVal strOut As String)
' ****************************
' This sub sends the hex codes
' ****************************
Dim numb1 As Integer, numb2 As Integer
Dim strRS As String
Dim i As Long
Dim newline(200) As String, outline(200) As String
Debug.Print "Sending IR - " & strOut
strRS = vbNullString
For i = 1 To Len(strOut)
newline(i) = Mid(strOut, i, 1)
Next
For i = 1 To Len(strOut) Step 2
If Asc(newline(i)) < 64 Then
numb1 = (Asc(newline(i)) - 48) * 16
strRS = strRS + Format(Hex(numb1 / 16), "0")
Else
numb1 = (Asc(newline(i)) - 55) * 16
strRS = strRS + Format(Hex(numb1 / 16), "0")
End If
If Asc(newline(i + 1)) < 64 Then
numb2 = (Asc(newline(i + 1)) - 48)
strRS = strRS + Format(Hex(numb2), "0")
Else
numb2 = (Asc(newline(i + 1)) - 55)
strRS = strRS + Format(Hex(numb2), "0")
End If
numb1 = numb1 + numb2
outline((i + 1) \ 2) = CByte(numb1)
strRS = strRS + " "
Next
With MSComm1
.RTSEnable = True
Sleep (20)
.OutBufferCount = 0
For i = 1 To (Len(strOut) / 2)
.Output = Chr(outline(i))
Next
Sleep (20)
.RTSEnable = False
End With
End Sub
この質問は、手順 2 と埋め込まれた IF ステートメントを含む 2 番目の For/Next ループに基づいています。ループの中で何が起こっているのでしょうか? numb1 と numb2
このループの目的は何ですか?