sahar15125
یک شنبه 30 آبان 1389, 18:27 عصر
برنامه زیر رو بعنوان فرستنده :
Dim Offset As Long
Dim FileData As Byte
Dim FileName As String
Private Sub Form_Load()
MSComm1.Settings = "28800,N,8,1"
MSComm1.InputLen = 1
MSComm1.CommPort = 2
MSComm1.PortOpen = True
Offset = 1
Open FileName For Binary Access Read As #1
End Sub
Private Sub MSComm1_OnComm()
If MSComm1.CommEvent = 2 Then
temp = MSComm1.Input
If Offset <= FileLen(FileName) Then
Get #1, Offset, FileData
q = FileData
MSComm1.Output = Format(q, "000")
Offset = Offset + 1
End If
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close #1
End Sub
و این قسمت هم بعنوان گیرنده نوشتم :
Dim ByteCount As Long
Dim FileData As Byte
Private Sub Form_Load()
MSComm1.Settings = "28800,N,8,1"
MSComm1.InputLen = 3
MSComm1.CommPort = 1
MSComm1.PortOpen = True
Open "c:\sample.txt" For Binary Access Write As #1
End Sub
Private Sub MSComm1_OnComm()
If MSComm1.CommEvent = 2 And MSComm1.InBufferCount > 0 Then
FileData = CInt(MSComm1.Input)
ByteCount = ByteCount + 1
Put #1, ByteCount, FileData
MSComm1.Output = Chr$(26)
End If
End Sub
Private Sub Command1_Click()
MSComm1.Output = Chr$(26)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close #1
End Sub
اما روی خط
MSComm1.CommPort = 2
از فرم اول خطا دارم
Invalid port number
لطفا راهنمایی کنین?!
و لطفا بگید این خط تنظیمات پورت COm رو چیکار می کنه؟
ممنون:ناراحت::قلب:
Dim Offset As Long
Dim FileData As Byte
Dim FileName As String
Private Sub Form_Load()
MSComm1.Settings = "28800,N,8,1"
MSComm1.InputLen = 1
MSComm1.CommPort = 2
MSComm1.PortOpen = True
Offset = 1
Open FileName For Binary Access Read As #1
End Sub
Private Sub MSComm1_OnComm()
If MSComm1.CommEvent = 2 Then
temp = MSComm1.Input
If Offset <= FileLen(FileName) Then
Get #1, Offset, FileData
q = FileData
MSComm1.Output = Format(q, "000")
Offset = Offset + 1
End If
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close #1
End Sub
و این قسمت هم بعنوان گیرنده نوشتم :
Dim ByteCount As Long
Dim FileData As Byte
Private Sub Form_Load()
MSComm1.Settings = "28800,N,8,1"
MSComm1.InputLen = 3
MSComm1.CommPort = 1
MSComm1.PortOpen = True
Open "c:\sample.txt" For Binary Access Write As #1
End Sub
Private Sub MSComm1_OnComm()
If MSComm1.CommEvent = 2 And MSComm1.InBufferCount > 0 Then
FileData = CInt(MSComm1.Input)
ByteCount = ByteCount + 1
Put #1, ByteCount, FileData
MSComm1.Output = Chr$(26)
End If
End Sub
Private Sub Command1_Click()
MSComm1.Output = Chr$(26)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close #1
End Sub
اما روی خط
MSComm1.CommPort = 2
از فرم اول خطا دارم
Invalid port number
لطفا راهنمایی کنین?!
و لطفا بگید این خط تنظیمات پورت COm رو چیکار می کنه؟
ممنون:ناراحت::قلب: