Rules | Recent posts | topic RSS | Search | Register  | Log in

Serial Port reading in Visual Basic

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing
Author Message
neoaspilet11



Joined: 29 Sep 2005
Posts: 273
Helped: 21
Location: Cebu, Philippines


Post29 Jan 2007 3:23   Serial Port reading in Visual Basic

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..
Back to top
buntheun



Joined: 20 Dec 2006
Posts: 78
Helped: 6
Location: Cambodia


Post31 Jan 2007 5:06   Re: Serial Port reading in Visual Basic

neoaspilet11 wrote:
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..



Sorry, but you need login in to view this attachment

Back to top
amihomo



Joined: 09 Jan 2007
Posts: 186
Helped: 23
Location: Karaj,Tehran,Iran


Post31 Jan 2007 13:49   Serial Port reading in Visual Basic

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
Very Happy
Back to top
CMOS



Joined: 06 Jan 2004
Posts: 672
Helped: 26


Post31 Jan 2007 15:24   Re: Serial Port reading in Visual Basic

amihomo wrote:
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
Very Happy
\
Why variant ??? Question 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
Back to top
mamu_s



Joined: 03 Feb 2007
Posts: 45
Helped: 2


Post03 Feb 2007 18:44   Re: Serial Port reading in Visual Basic

serial port using visual basic...it teach you step by step...[/quote]


Sorry, but you need login in to view this attachment

Back to top
dnhuruag



Joined: 23 Jul 2007
Posts: 17


Post09 Aug 2007 17:44   Re: Serial Port reading in Visual Basic

ahhh... how i wish i could have a copy of that step by step.... im am using vb6 also and incoming data from microcontroller...
Back to top
CMOS



Joined: 06 Jan 2004
Posts: 672
Helped: 26


Post09 Aug 2007 23:46   Re: Serial Port reading in Visual Basic

dnhuruag wrote:
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!
Back to top
aamiralikhoja



Joined: 11 Aug 2004
Posts: 88


Post26 Aug 2007 2:48   Re: Serial Port reading in Visual Basic

Search msdn documentation for Mscom
Back to top
eca



Joined: 25 Jul 2006
Posts: 5
Location: iran


Post26 Aug 2007 16:16   Re: Serial Port reading in Visual Basic

thank Very Happy
Back to top
karim aslan



Joined: 14 Mar 2007
Posts: 7
Location: egypt


Post27 Aug 2007 20:36   Re: Serial Port reading in Visual Basic

hiiiiiiiiii
are u sure that

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

from the properties window
Back to top
CMOS



Joined: 06 Jan 2004
Posts: 672
Helped: 26


Post28 Aug 2007 5:11   Re: Serial Port reading in Visual Basic

karim aslan wrote:
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.
Back to top
bhavrana



Joined: 06 Sep 2007
Posts: 3


Post07 Sep 2007 6:47   Serial Port reading in Visual Basic

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



Joined: 08 Sep 2007
Posts: 4


Post08 Sep 2007 22:05   Re: Serial Port reading in Visual Basic

search stepper motor control in google
Back to top
buntheun



Joined: 20 Dec 2006
Posts: 78
Helped: 6
Location: Cambodia


Post15 Oct 2007 11:21   Re: Serial Port reading in Visual Basic

bhavrana wrote:
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
Back to top
nishal



Joined: 04 May 2007
Posts: 49
Helped: 3
Location: KOCHI, INDIA


Post19 Oct 2007 5:46   Re: Serial Port reading in Visual Basic

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
Back to top
madicalphy



Joined: 22 Jul 2007
Posts: 35
Helped: 3


Post28 Aug 2008 6:53   Re: Serial Port reading in Visual Basic

good help in steps
Back to top
DB_Man



Joined: 28 Aug 2008
Posts: 4


Post29 Aug 2008 3:15   Serial Port reading in Visual Basic

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
Back to top
Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing
Page 1 of 1 All times are GMT + 1 Hour


Abuse
Administrator
Moderators
topic RSS 
sitemap