vb6 - understanding this VB code -


can try wrap brain around one? thought ensuring there 2 bytes in hex byte , ensuring values between 0 -9 , a-f no.

a snippet of program infrared controller/blaster. subroutine send actual signals (or other codes) out serial port controller finish job.

sample call:

sendcode ("04241001") 

the vb6 code says:

public sub sendcode(byval strout string) ' **************************** ' sub sends hex codes ' ****************************   dim numb1 integer, numb2 integer dim strrs string dim long dim newline(200) string, outline(200) string  debug.print "sending ir - " & strout      strrs = vbnullstring      = 1 len(strout)         newline(i) = mid(strout, i, 1)     next      = 1 len(strout) step 2         if asc(newline(i)) < 64             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             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      mscomm1         .rtsenable = true         sleep (20)         .outbuffercount = 0         = 1 (len(strout) / 2)             .output = chr(outline(i))         next         sleep (20)         .rtsenable = false     end  end sub 

the question based around second for/next loop step 2 , embedded if statements. going on inside loop? numb1 , numb2

what purpose of loop?

it converts hex string binary byte string, sends binary byte string. converts binary bytes hex (strrs) can check conversion , output. check/debug string not used anything, if put break point in there can check values.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -