PC to Transmitter Through VB6
PC to Transmitter Through VB6
PC to Transmitter Through VB6
PC to Transmitter Through VB6
PC to Transmitter Through VB6
PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6
PC to Transmitter Through VB6 PC to Transmitter Through VB6
PC to Transmitter Through VB6
Go Back  Xtreme Visual Basic Talk > > > PC to Transmitter Through VB6


Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2009, 07:50 AM
sumitece87 sumitece87 is offline
Newcomer
 
Join Date: Mar 2009
Posts: 1
Default PC to Transmitter Through VB6


Hi there,

I am currently working on a project requiring to Send data from PC to a transmitter through VB6 using RS232 cable...

I am not able to use proper PORT while connection...

Can anybody PLZ help me in that?

My VB code:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim SSS As String
Dim Cnt, Cnt1, inby, inby1 As Integer


Private Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Private Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()
MSComm1.PortOpen = True
Out Val("&h378"), 0
End Sub

Private Sub Timer1_Timer()
inby = Inp(Val("&h379"))

If (inby And &H8) = &H8 Then
Seluser = 1
Out Val("&h378"), 1
Label6.Caption = "User No : 1"
Sleep (100)
Open "c:\Mls_Encdec\User1.txt" For Input As #1
Input #1, SSS
Text2.Text = Left$(SSS, 16)
Text3.Text = Right$(SSS, 16)
Close #1
Call Convert_And_Send
Sleep 100
Out Val("&h378"), 0
ElseIf (inby And &H10) = &H10 Then
Seluser = 2
Out Val("&h378"), 1
Label6.Caption = "User No : 2"
Sleep (100)
Open "c:\Mls_Encdec\User2.txt" For Input As #1
Input #1, SSS
Text2.Text = Left$(SSS, 16)
Text3.Text = Right$(SSS, 16)
Close #1
Call Convert_And_Send
Sleep 100
Out Val("&h378"), 0
ElseIf (inby And &H20) = &H20 Then
Seluser = 3
Out Val("&h378"), 1
Label6.Caption = "User No : 3"
Sleep (100)
Open "c:\Mls_Encdec\User3.txt" For Input As #1
Input #1, SSS
Text2.Text = Left$(SSS, 16)
Text3.Text = Right$(SSS, 16)
Close #1
Call Convert_And_Send
Sleep 100
Out Val("&h378"), 0
ElseIf (inby And &H40) = &H40 Then
Seluser = 4
Out Val("&h378"), 1
Label6.Caption = "User No : 4"
Sleep (100)
Open "c:\Mls_Encdec\User4.txt" For Input As #1
Input #1, SSS
Text2.Text = Left$(SSS, 16)
Text3.Text = Right$(SSS, 16)
Close #1
Call Convert_And_Send
Sleep 100
Out Val("&h378"), 0


End If







End Sub


Private Sub Convert_And_Send()
Text1 = ""

Text2.Text = UCase(Text2.Text)
Text3.Text = UCase(Text3.Text)

Splen = 16 - Len(Text2.Text)
Text2.Text = Text2.Text & Space(Splen)

Splen = 16 - Len(Text3.Text)
Text3.Text = Text3.Text & Space(Splen)


For i = 1 To 8

Mybyte = Asc(Mid$(Text2.Text, i, 1))

If (Mybyte And &H80) = &H80 Then
Udata1(i, 1) = 116
Else
Udata1(i, 1) = 11
End If

If (Mybyte And &H40) = &H40 Then
Udata1(i, 2) = 116
Else
Udata1(i, 2) = 11
End If

If (Mybyte And &H20) = &H20 Then
Udata1(i, 3) = 116
Else
Udata1(i, 3) = 11
End If

If (Mybyte And &H10) = &H10 Then
Udata1(i, 4) = 116
Else
Udata1(i, 4) = 11
End If

If (Mybyte And &H8) = &H8 Then
Udata1(i, 5) = 116
Else
Udata1(i, 5) = 11
End If

If (Mybyte And &H4) = &H4 Then
Udata1(i, 6) = 116
Else
Udata1(i, 6) = 11
End If

If (Mybyte And &H2) = &H2 Then
Udata1(i, 7) = 116
Else
Udata1(i, 7) = 11
End If

If (Mybyte And &H1) = &H1 Then
Udata1(i, 8) = 116
Else
Udata1(i, 8) = 11
End If

'''''''''

Mybyte = Asc(Mid$(Text3.Text, i, 1))

If (Mybyte And &H80) = &H80 Then
Udata2(i, 1) = 92
Else
Udata2(i, 1) = 35
End If

If (Mybyte And &H40) = &H40 Then
Udata2(i, 2) = 92
Else
Udata2(i, 2) = 35
End If

If (Mybyte And &H20) = &H20 Then
Udata2(i, 3) = 92
Else
Udata2(i, 3) = 35
End If

If (Mybyte And &H10) = &H10 Then
Udata2(i, 4) = 92
Else
Udata2(i, 4) = 35
End If

If (Mybyte And &H8) = &H8 Then
Udata2(i, 5) = 92
Else
Udata2(i, 5) = 35
End If

If (Mybyte And &H4) = &H4 Then
Udata2(i, 6) = 92
Else
Udata2(i, 6) = 35
End If

If (Mybyte And &H2) = &H2 Then
Udata2(i, 7) = 92
Else
Udata2(i, 7) = 35
End If

If (Mybyte And &H1) = &H1 Then
Udata2(i, 8) = 92
Else
Udata2(i, 8) = 35
End If

For j = 1 To 8
Text1.Text = Text1.Text & Chr(Udata1(i, j)) & " " & Chr(Udata2(i, j)) & vbCrLf

Next

Next

For k = 1 To 30
Sstr = "[1" & Text2.Text & "]"
Sleep (2)
MSComm1.Output = Sstr
'DoEvents
Next

For k = 1 To 30
Sstr = "[2" & Text3.Text & "]"
Sleep (2)
MSComm1.Output = Sstr
'DoEvents
Next

MsgBox "Sent"
End Sub


-----------------------------------------------------------------------

Now that i have written codes, connected transmitter kit to PC, but it is showing INVALID PORT NUMBER or sometimes THE PORT IS ALREADY OPEN?

Plz tell me how to eliminate these errors...
Reply With Quote
  #2  
Old 03-25-2009, 10:34 AM
loquin's Avatar
loquinPC to Transmitter Through VB6 loquin is offline
Google Hound

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,400
Default

inpout32 is used with the parallel (printer) port.

Take a look at the mscomm control. Plan on using the event driven methods, rather than the polling method.
__________________
Lou
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
PC to Transmitter Through VB6
PC to Transmitter Through VB6
PC to Transmitter Through VB6 PC to Transmitter Through VB6
PC to Transmitter Through VB6
PC to Transmitter Through VB6
PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6 PC to Transmitter Through VB6
PC to Transmitter Through VB6
PC to Transmitter Through VB6
 
PC to Transmitter Through VB6
PC to Transmitter Through VB6
 
-->