Make your own free website on Tripod.com

Page 16

 

Home
Up

7.2 Visual Basic 6 Coding for RIVD 

 

Option Explicit

Private Sub Form_Load()

Dim UserName As String

Dim Password As String

verify user name and password

UserName = InputBox("Please enter the user name")

Password = InputBox("Please enter the password")

If (UserName = "ErangaB") And (Password = "RIVD") Then

   MsgBox "The login is correct!"

Else

   MsgBox "Incorrect Login!"

   End

End If

' tells the MSComm control to fire the comEvReceive event

' when there are at least one byte available in the buffer

MSComm1.RThreshold = 1

' When Inputting Data, tell the MSComm control to only give

' us one byte at a time when we request data from the buffer.

MSComm1.InputLen = 1

' 2400 Baud, No Parity, 8 Data Bits, 1 Stop Bit

MSComm1.Settings = "9600,N,8,1"

' Open COM1

MSComm1.CommPort = 2

MSComm1.PortOpen = True

If Not MSComm1.PortOpen Then

MsgBox "Cannot open port 2"

End If

 

End Sub

 

Private Sub Form_Unload(Cancel As Integer)

' disconnect the remote access and finishes data process

MSComm1.CommPort = False

End Sub

 

Private Sub MSComm1_OnComm()

Static sDigits As String   ' Holds the ten number string

Dim sData As String        ' Holds number entered at keypad

                           ' in recieved Format

 

 

Dim lData As Long          ' Holds number entered at keypad as number

Dim iName As String

 

' If comEvReceive Event then get data and display

If MSComm1.CommEvent = comEvReceive Then

   Beep

 

    sData = MSComm1.Input  ' Get data (the number) [1 byte]

    lData = Asc(sData)     ' Get NumericaL Value of sData

   

    sDigits = sDigits & CStr(lData) ' Append the digit to sDigits

 

 

 

Home ] Up ]

Send mail to wmecproject@lycos.com with questions or comments about this web site.
Last modified: July 13, 2002