Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Serial Port reading in Visual Basic

Status
Not open for further replies.

neoaspilet11

Full Member level 5
Joined
Sep 29, 2005
Messages
277
Helped
29
Reputation
56
Reaction score
8
Trophy points
1,298
Location
Cebu, Philippines
Activity points
4,048
control stepper using comport vb6

Hello Guys,
Need some help..
1.) I tried to read the input of MSCOM in the code below

Text1.text = MsComm1.input

but it doesnt show anything on the text box. But I put a break point after the line above, and there is a data at MsComm input.

Please help me on this..

Thanks..
 

neoaspilet11 said:
Hello Guys,
Need some help..
1.) I tried to read the input of MSCOM in the code below

Text1.text = MsComm1.input

but it doesnt show anything on the text box. But I put a break point after the line above, and there is a data at MsComm input.

Please help me on this..

Thanks..
 

hi

you must define a buffer variable of type "variant" and then read the mscomm onto the buffer , then put the buffer in the Text1.text .

regards
:D
 

amihomo said:
hi

you must define a buffer variable of type "variant" and then read the mscomm onto the buffer , then put the buffer in the Text1.text .

regards
:D
\
Why variant ??? :?: MsComm.Input return STRING data type...so you should declare Buffer variable as string.


Anyways here is how you do it.
Code:
Private Sub Form_Load()
    MSComm1.Settings = "9600,n,8,1"
    MSComm1.CommPort = 1
    MSComm1.PortOpen = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
End Sub

Private Sub MSComm1_OnComm()
    If MSComm1.CommEvent = comEvReceive Then
        Text1.Text = MSComm1.Input
    End If
End Sub
 

serial port using visual basic...it teach you step by step...[/quote]
 
  • Like
Reactions: rdiaz

    rdiaz

    Points: 2
    Helpful Answer Positive Rating
ahhh... how i wish i could have a copy of that step by step.... im am using vb6 also and incoming data from microcontroller...
 

dnhuruag said:
ahhh... how i wish i could have a copy of that step by step.... im am using vb6 also and incoming data from microcontroller...
You can download it. You have enough points for that!
 

hiiiiiiiiii
are u sure that

Rthreshold=1 mustn't be zero for receiving
Sthreshold=1 for sending

from the properties window
 

karim aslan said:
hiiiiiiiiii
are u sure that

Rthreshold=1 mustn't be zero for receiving
Sthreshold=1 for sending

from the properties window
If RThreshold=1, the OnComm event of MSCOMM is fired when the receive buffer has 1 character in it. So on every character received, OnComm will be fired. If you want to receive 10 characters and want OnComm to be fired only once after receiving all 10 of them, make RThreshold=10.

SThreshold defines how many characters should be present in transmit buffer before transmission begins. SThreshold=1 means the character will be immediately transmitted, once placed in buffer. IF you want transmission to begin after 10 characters, make SThreshold=10. Generally it is kept 1.
 

Need help in Stepper Motor Control through Parallel Port ..I need to drive 5 motors through parallel port [please help me out
 

search stepper motor control in google
 

bhavrana said:
Need help in Stepper Motor Control through Parallel Port ..I need to drive 5 motors through parallel port [please help me out
this the sample for you.....

Code:
private sub command1_click()
lefts=false
rights=true

Do
    DoEvents
out &H378,1
call delay
out &H378,2
call delay
out &H378,4
call delay
out &H378,8
call delay
loop until lefts=true
end sub

Sub delay ()
times= timer
Do 
Doevents
loop until time>=times+0.01
end sub

private sub command2_click()
lefts=false
rights=true

Do
    DoEvents
out &H378,1
call delay
out &H378,2
call delay
out &H378,4
call delay
out &H378,8
call delay
loop until lefts=true
end sub
 

Hi,
Here is my step which i uses for Com port interfacing

Place mscomm in the form
place a timer in the form
set for necessary interval say 300ms
in the timer1.timer event, assign the mscomm.input to a variable and process the variable
the process will continue until u stop the timer event

Good Luck

Nishal
 

Hi.
For the delay you could also use

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


In your code use

Sleep x ' whereas x stands for milliseconds to wait

Cheers
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top