473,396 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

About send data to Com-port?

I want to program a program sending data to Comport, which connect to RS-232.
Here is the code:
Private Sub Form_Load()
Label1.Caption = "Finding a width from Barcode"
Label1.FontSize = 12
Label1.Alignment = 2
Label1.Tag = 0
Label2.Caption = "Barcode:"
Label2.FontSize = 10
Label3.Caption = "Width:"
Label3.FontSize = 10
Label3.Enabled = False
Text1.Text = ""
Text1.FontSize = 10
Text2.Text = ""
Text2.FontSize = 10
Text2.Enabled = False
Command1.Caption = "Search"
Command1.FontSize = 10
Command2.Caption = "Clear"
Command2.FontSize = 10
Command3.Caption = "Quit"
Command3.FontSize = 10
MSComm1.Settings = "9600,n,8,1"

End Sub
Private Sub Command1_Click()
Dim Target As String
Dim Current As String
MSComm1.PortOpen = True
MSComm1.Output = Text2.Text
MSComm1.PortOpen = False
Target = Text1.Text
Open "Test1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, Current
If InStr(Current, Target) Then
Label3.Enabled = True
Text2.Enabled = True
Text2.Text = Right(Current, 4)
Else
MsgBox ("Cannot find this barcode,please try again.")
Exit Do
End If
Loop
Close #1
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text2.Enabled = False
Label3.Enabled = False
End Sub
Private Sub Command3_Click()
Close #1
End
End Sub

Private Sub Option1_Click()
Select Case Index
Case 0
MSComm1.CommPort = 1
If MSComm1.PortOpen Then
MsgBox "Sorry,COM1 was used,please choose another one."
End If

Case 1
MSComm1.CommPort = 2
If MSComm1.PortOpen Then
MsgBox "Sorry,COM1 was used,please choose another one."
End If
End Select
End Sub
It is not working.
Anyone can help me fix the problem?
Thanks a lot!
Sep 5 '06 #1
1 3068
sashi
1,754 Expert 1GB
Hi there,

kidly refer to below attached links, hope it helps you to get started with.. take care my fren.. :)

http://www.lvr.com/serport.htm
http://prism.mem.drexel.edu/stanciu/Web_page/SerialVB.htm

I want to program a program sending data to Comport, which connect to RS-232.
Here is the code:
Private Sub Form_Load()
Label1.Caption = "Finding a width from Barcode"
Label1.FontSize = 12
Label1.Alignment = 2
Label1.Tag = 0
Label2.Caption = "Barcode:"
Label2.FontSize = 10
Label3.Caption = "Width:"
Label3.FontSize = 10
Label3.Enabled = False
Text1.Text = ""
Text1.FontSize = 10
Text2.Text = ""
Text2.FontSize = 10
Text2.Enabled = False
Command1.Caption = "Search"
Command1.FontSize = 10
Command2.Caption = "Clear"
Command2.FontSize = 10
Command3.Caption = "Quit"
Command3.FontSize = 10
MSComm1.Settings = "9600,n,8,1"

End Sub
Private Sub Command1_Click()
Dim Target As String
Dim Current As String
MSComm1.PortOpen = True
MSComm1.Output = Text2.Text
MSComm1.PortOpen = False
Target = Text1.Text
Open "Test1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, Current
If InStr(Current, Target) Then
Label3.Enabled = True
Text2.Enabled = True
Text2.Text = Right(Current, 4)
Else
MsgBox ("Cannot find this barcode,please try again.")
Exit Do
End If
Loop
Close #1
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text2.Enabled = False
Label3.Enabled = False
End Sub
Private Sub Command3_Click()
Close #1
End
End Sub

Private Sub Option1_Click()
Select Case Index
Case 0
MSComm1.CommPort = 1
If MSComm1.PortOpen Then
MsgBox "Sorry,COM1 was used,please choose another one."
End If

Case 1
MSComm1.CommPort = 2
If MSComm1.PortOpen Then
MsgBox "Sorry,COM1 was used,please choose another one."
End If
End Select
End Sub
It is not working.
Anyone can help me fix the problem?
Thanks a lot!
Sep 5 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: | last post by:
so i am using Dreamweaver; and I need to be able to have multiple pages post to a page called page6_1.asp from there; i give people the ability to either '1 - save definition as new report'; '2...
2
by: Fatih BOY | last post by:
Hi, I want to send a report from a windows application to a web page like 'report.asp' Currently i can send it via post method with a context like local=En&Username=fatih&UserId=45&Firm=none...
13
by: Manfred Braun | last post by:
Hi All, I am trying to understand the blocking method socket.Send(). The call blocks as expected, but does this mean, it returnes after the underlying TCP layer got a confirmation, that the send...
9
by: eswanson | last post by:
I have a web page I need to post a file plus some other fields to it. How can I do this from a asp.net page. I know I can send individual fields to the other page, but how do I send a file to the...
2
by: ejs | last post by:
Please read the entire reponse, hopefully this clears up your questions. The data used that needs to go into the batchupload page comes from a server. My problem is that currently I write a file...
9
by: Marty | last post by:
Hi, I have an application bound to a database through ADO.NET, how can it be notified when the database content is updated by a third party ? If you have any idea or link that I could read I...
3
by: nephish | last post by:
lo there all ! i finally got my script to receive info on a socket. but i need to somehow set up a loop that will continue to listen for more info comming across the same socket. the way it...
3
by: Mark | last post by:
Hi - The da.Fill(ds, "TableName") method is a really nice way to bring data from a database into your VB.Net application. My question is this: Is there an equally nice method to send data...
1
by: Max2006 | last post by:
Hi, To protect my WCF service boundaries, I assign a unique support ticket to all server side exceptions, log them and send a general FaultException to client that only include the support...
8
by: Frank Millman | last post by:
Hi all I have been using my own home-brewed client/server technique for a while, using socket and select. It seems to work ok. The server can handle multiple clients. It does this by creating a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.