Visual Basic Assistance

I am trying to write a macro for the Reflection IBM Terminal.  I have most of the code done but I am having issues with the UserForm TextBox and Looping the macro based on the TextBox information.  

The UserForm has 2 TextBoxs Module and SerialNumber.  The user has to input the module then add all the serial numbers that need to be updated to the module.  The SerialNumber text box will have multiple serial numbers that I need to be updated using the macro.  I also need the macro to loop until all the serial numbers are updated.

Any help is greatly appreciated.  If you aren't sure but could point me in the general direction that I need to go in as far as what I need to be using will also help a lot.   Thanks

 

Here is my code so far

 

<code>

  1. Public SerialNumber As String
  2. Public Module As String
  3. ------------------------------------------------------
  4. Sub Passes()
  5. UserForm1.Show
  6. End Sub
  7. _____________________________________________
  8. Sub Passcode()
  9. With Session
  10. ' Base Macro for MC04 Update
  11. .TransmitTerminalKey rcIBMClearKey
  12. .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
  13. .WaitForEvent rcEnterPos, "30", "0", 1, 1
  14. .TransmitANSI "/for jdopmcm"
  15. .TransmitTerminalKey rcIBMEnterKey
  16. .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
  17. .WaitForEvent rcEnterPos, "30", "0", 15, 11
  18. .WaitForDisplayString "BKG", "30", 15, 5
  19. '.SetMousePos 15, 11
  20. .TransmitANSI SerialNumber
  21. .TransmitTerminalKey rcIBMPf4Key
  22. .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
  23. .WaitForEvent rcEnterPos, "30", "0", 16, 6
  24. '.SetMousePos 16, 27
  25. .TransmitTerminalKey rcIBMTabKey
  26. .TransmitTerminalKey rcIBMTabKey
  27. .TransmitANSI Module
  28. .TransmitTerminalKey rcIBMEnterKey
  29. 'Loop until all SerialNumber are update
  30. End With
  31. End Sub

</code>

 

Ok figured it out but now I have another issue.  I got the split function to work after a lot of reading then finally realizing that I am using VBA5.  Split is working but I get the error that it cannot assign to array.

Here is my Split Function:

  1. Public Function Split(ByVal sIn As String, Optional sDelim As _
  2. String, Optional nLimit As Long = -1, Optional bCompare As _
  3. Long = vbBinaryCompare) As Variant
  4. Dim sRead As String, sOut() As String, nC As Integer
  5. If sDelim = "" Then
  6. Split = sIn
  7. End If
  8. sRead = ReadUntil(sIn, sDelim, bCompare)
  9. Do
  10. ReDim Preserve sOut(nC)
  11. sOut(nC) = sRead
  12. nC = nC + 1
  13. If nLimit <> -1 And nC >= nLimit Then Exit Do
  14. sRead = ReadUntil(sIn, sDelim)
  15. Loop While sRead <> ""
  16. ReDim Preserve sOut(nC)
  17. sOut(nC) = sIn
  18. Split = sOut
  19. End Function

 

Here is my sample code that I am trying to get working:

 

Sub code()

    With Session

        arySample = Split(Number, vbCr)

        For i = 0 To UBound(arySample)

            msgbox arySample(i)

        Next i