Advertisement
phillips321

vb code

Sep 23rd, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub SendWithScrollCrontrol_Click()
  2.     Call AllOff ' set all off
  3.    
  4.     Dim ToSend As String
  5.     '         123456781234567812345678123456781234567812345678
  6.    'ToSend = "010101010101010101010101010101010101010101010101"
  7.    'ToSend = "001100110011001100110011001100110011001100110011"
  8.    'ToSend = "000111000111000111000111000111000111000111000111"
  9.    ToSend = "000011110000111100001111000011110000111100001111"
  10.     Dim ToSendLength As Integer
  11.     ToSendLength = Len(ToSend)
  12.    
  13.     Dim PosInSendString As Integer
  14.     PosInSendString = 1
  15.    
  16.     MsgBox (ToSend)
  17.     MsgBox (ToSendLength)
  18.    
  19.     Do Until PosInSendString > ToSendLength ' keep going until we have sent all bits
  20.        If ScrollLockOn = False Then 'PC has control
  21.            
  22.             ' change num value
  23.            If Mid$(ToSend, PosInSendString, 1) = "0" Then
  24.                 Call NumOff_Click ' send 0
  25.            Else
  26.                 Call NumOn_Click  ' send 1
  27.            End If
  28.            
  29.            
  30.             'MsgBox (PosInSendString)
  31.            Let PosInSendString = PosInSendString + 1 ' add 1 to value of PosInSendString
  32.        
  33.             ' turn scroll lock on
  34.            Call ScrollOn_Click ' teensy is now given control
  35.    
  36.         End If
  37.         DoEvents 'hangs without this
  38.    Loop
  39.        
  40.     Call AllOff ' set all off
  41.    MsgBox ("finished")
  42. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement