i need ur help urgently, friends
i am now making a project.
now i come across one vb problem.
i can't control mscomm's port i mean ( open and close )
i can make it with C but i prefer cos i wanna my project excellent interface.
i am now using xp and i also test it with Win(Me) but doesn't work, too.i mean even to open the port.
well my project is to send the ASCII characters from one computer to the other stuff with wireless.
i have already made system and now i am to test it with software.
here my software for access point and access client.
pls help me out if any bug u see cos i am so new to vb.
Access Point
Dim k As Integer
Dim binary As String
Private Sub Command1_Click()
Dim word As String
Dim i As Integer, j As Integer
Dim cha As String
Dim deci As Integer
Dim re As Integer
word = Trim(Text1.Text)
For i = 1 To i = Len(word)
cha = Right$(word, Len(word) - i + 1)
deci = AscW(cha)
Do While deci > 0
re = deci Mod 2
binary = binary & CStr(re)
deci = deci / 2
Loop
binary = Trim$(binary)
For j = 1 To j = 8 - Len(binary)
binary = binary & "0"
Next
MSComm1.DTREnable = True
Timer1.Enabled = True
Do While Timer1.Enabled = True
Loop
timer1.enabled=false
Next
MSComm1.DTREnable = False
End Sub
Private Sub Form_Load()
k = 1
MSComm1.PortOpen = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
Private Sub Timer1_Timer()
If AscB(CInt(Right$(binary, k))) = 49 Then
MSComm1.RTSEnable = True
Else: MSComm1.RTSEnable = False
End If
k = k + 1
If k > 8 Then
k = 1
Timer1.Enabled = False
End If
End Sub
Private Sub Timer2_Timer()
Form2.Caption = Right$(Form2.Caption, Len(Form2.Caption) - 1) & Left$(Form2.Caption, 1)
End Sub
Access Client
Dim bi As String
Dim k As Integer
Dim deci As Integer
Dim word As String
Public Function ConvertBinaryToDecimal(BinVal As String) As String
Dim iVal#, temp#, i%, Length%
Length = Len(BinVal)
For i = 0 To Length - 1
temp = CInt(Mid(BinVal, Length - i, 1))
iVal = iVal + (temp * (2 ^ i))
Next i
ConvertBinaryToDecimal = iVal
End Function
Private Sub Form_Load()
MSComm1.PortOpen = True
Timer1.Enabled = True
k = 1
bi = ""
End Sub
Private Sub Timer1_Timer()
If MSComm1.DSRHolding = True Then
Timer2.Enabled = True
Else: Timer2.Enabled = False
End If
End Sub
Private Sub Timer2_Timer()
If (MSComm1.CommEvent = comEvCTS) Then
bi = bi & "1"
Else: bi = bi & "0"
End If
k = k + 1
If k > 8 Then
k = 1
deci = ConvertBinaryToDecimal(Trim$(bi))
word = Chr(deci)
Label1.Caption = Label1.Caption + word
End If
End Sub
Private Sub Timer3_Timer()
Form2.Caption = Right$(Form2.Caption, Len(Form2.Caption) - 1) & Left$(Form2.Caption, 1)
End Sub
i am now making a project.
now i come across one vb problem.
i can't control mscomm's port i mean ( open and close )
i can make it with C but i prefer cos i wanna my project excellent interface.
i am now using xp and i also test it with Win(Me) but doesn't work, too.i mean even to open the port.
well my project is to send the ASCII characters from one computer to the other stuff with wireless.
i have already made system and now i am to test it with software.
here my software for access point and access client.
pls help me out if any bug u see cos i am so new to vb.
Access Point
Dim k As Integer
Dim binary As String
Private Sub Command1_Click()
Dim word As String
Dim i As Integer, j As Integer
Dim cha As String
Dim deci As Integer
Dim re As Integer
word = Trim(Text1.Text)
For i = 1 To i = Len(word)
cha = Right$(word, Len(word) - i + 1)
deci = AscW(cha)
Do While deci > 0
re = deci Mod 2
binary = binary & CStr(re)
deci = deci / 2
Loop
binary = Trim$(binary)
For j = 1 To j = 8 - Len(binary)
binary = binary & "0"
Next
MSComm1.DTREnable = True
Timer1.Enabled = True
Do While Timer1.Enabled = True
Loop
timer1.enabled=false
Next
MSComm1.DTREnable = False
End Sub
Private Sub Form_Load()
k = 1
MSComm1.PortOpen = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
Private Sub Timer1_Timer()
If AscB(CInt(Right$(binary, k))) = 49 Then
MSComm1.RTSEnable = True
Else: MSComm1.RTSEnable = False
End If
k = k + 1
If k > 8 Then
k = 1
Timer1.Enabled = False
End If
End Sub
Private Sub Timer2_Timer()
Form2.Caption = Right$(Form2.Caption, Len(Form2.Caption) - 1) & Left$(Form2.Caption, 1)
End Sub
Access Client
Dim bi As String
Dim k As Integer
Dim deci As Integer
Dim word As String
Public Function ConvertBinaryToDecimal(BinVal As String) As String
Dim iVal#, temp#, i%, Length%
Length = Len(BinVal)
For i = 0 To Length - 1
temp = CInt(Mid(BinVal, Length - i, 1))
iVal = iVal + (temp * (2 ^ i))
Next i
ConvertBinaryToDecimal = iVal
End Function
Private Sub Form_Load()
MSComm1.PortOpen = True
Timer1.Enabled = True
k = 1
bi = ""
End Sub
Private Sub Timer1_Timer()
If MSComm1.DSRHolding = True Then
Timer2.Enabled = True
Else: Timer2.Enabled = False
End If
End Sub
Private Sub Timer2_Timer()
If (MSComm1.CommEvent = comEvCTS) Then
bi = bi & "1"
Else: bi = bi & "0"
End If
k = k + 1
If k > 8 Then
k = 1
deci = ConvertBinaryToDecimal(Trim$(bi))
word = Chr(deci)
Label1.Caption = Label1.Caption + word
End If
End Sub
Private Sub Timer3_Timer()
Form2.Caption = Right$(Form2.Caption, Len(Form2.Caption) - 1) & Left$(Form2.Caption, 1)
End Sub