Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
LinkBack Thread Tools Display Modes
Old 13th June 2008, 05:50 AM   (permalink)
Arrow MSComm String Data Out Help

Hi, I can send a single character when I press a command button in VB.

Here is the code

Code:
Private Sub Command1_Click()
MSComm1.Output = "A" + Chr(13)
End Sub
Now I need to send a string which is typed in the textbox when I pressed the command button. Can anybody help me out to do this?

Thanks
Suraj143 is offline  
Old 13th June 2008, 06:37 AM   (permalink)
Default

Try,
Code:
Private Sub Command1_Click()
    MSComm1.Output = Text1.Text & vbCr
End Sub
Mike.
Pommie is online now  
Old 13th June 2008, 06:44 AM   (permalink)
Default

Hi Mike thats what I was looking, I couldn't find this on the net.

Ahh this will send a string what I type in the Text1 box.

I'll try to add your code.Can I change the character length also,I mean character length (Word) must not exceed 10 characters.Its never mind I'll try to solve that out.

Thanks Mike
Suraj143 is offline  
Old 13th June 2008, 07:00 AM   (permalink)
Default

You could do,
Code:
Private Sub Command1_Click()
Dim Temp As String
    Temp = Text1.Text
    If Len(Temp) > 10 Then Temp = Left(Temp, 10)
    MSComm1.Output = Temp & vbCr
End Sub
Mike.
Pommie is online now  
Old 13th June 2008, 07:07 AM   (permalink)
Default

Hi Mike now I got it.Thanks for the superb code.All I understand except the Left(Temp, 10) part.Does it move left when it receive 11 characters?So every time it is a below 10 letter word.
Suraj143 is offline  
Old 13th June 2008, 07:16 AM   (permalink)
Default

Left just returns a number of characters from the beginning of the string and so, Temp=Left("Hello World",5) would result in Temp containing "Hello".

Mike.
Pommie is online now  
Old 13th June 2008, 07:20 AM   (permalink)
Default

Quote:
Originally Posted by Pommie View Post
Left just returns a number of characters from the beginning of the string and so, Temp=Left("Hello World",5) would result in Temp containing "Hello".

Mike.
Totally understood.I got everything from you that I was looking everywhere.

Thanks Again.
Suraj143 is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
String in pic16f877 and gsm neelam29 Micro Controllers 1 19th March 2008 06:04 PM
float to string conversion for PIC fzn10 Micro Controllers 6 10th August 2006 01:50 PM
Can chr$(0) be received using mscomm in VB? StupidDum Micro Controllers 4 23rd May 2004 01:12 PM
String Variable? Timmymna Micro Controllers 1 3rd May 2004 12:03 AM
mscomm help xjackal Micro Controllers 3 22nd February 2004 09:50 PM



All times are GMT. The time now is 03:05 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

eXTReMe Tracker