Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Send and receive data vi modem by mscomm in VB

Posted on 2003-11-29
11
Medium Priority
?
432 Views
Last Modified: 2013-12-13
HI
I 'm VB programmer and I 'm writing programm that send and receive data via modem but I don't know how can recognize that when my all data has been received and close my file.
I open the file and i read file for binary and when i read file in the receive procedure i must recognize end of file and colse my file that data save it and close this file
please help me that recognize end of file .
I have another problem: i don't know how can send text that write in text box and show this text in another textbox( in receiver )
Thanks
0
Comment
Question by:asid_rock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
11 Comments
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9849085
when you are reading and sending the data at the end of the file send a delimeter something like ~^~^~
at the recieving end if you find this pattern you know that the end of the file has been reached.

"I have another problem: i don't know how can send text that write in text box and show this text in another textbox( in receiver )"
if you want to send a character at a time then in the keypress event send the chr of the ascii value that u get. Prefer sending the data at one go its more optimum
0
 

Author Comment

by:asid_rock
ID: 9874741
hi
I have a problem with transfer file I want send 1 byte of file and send it to another pc and this operation until full of file transmited .and all of data transmit byte byte.
what variable do I use?and how can srite this programm in VB
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9879839
use a byte or you can use the chr function and convert to ascii and transmit as string.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:asid_rock
ID: 9881741
Hi bhagyesht
Thanks for Reply but I don't know how can read a file byte byte and then every byte sne to output buffer.?
Please help me.
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9894525
if you know how to read a string read a string by converting the byte to a string. or there is a sample in msdn.I shall post it later in the day
0
 

Author Comment

by:asid_rock
ID: 9900161
Hi bhagyesht
Thanks for Replay . I don't know how can send a byte with mscomm when inputmode=Binary.If you can know send me code.or tell me how can send several character in Binary mode with mscomm.
my primary goal is that send a file in Binary mode with mscomm.
please help me
thanks
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9901759
ok this code sends the textbox keys pressed one at a time

Private Sub Text1_KeyPress (KeyAscii As Integer)
   Dim Buffer as Variant
   
   ' Set and open port
   MSComm1.CommPort = 1
   MSComm1.PortOpen = True

   Buffer = Chr$(KeyAscii)
   MSComm1.Output = Buffer
End Sub



bhagyesh
0
 
LVL 9

Accepted Solution

by:
bhagyesht earned 500 total points
ID: 9901807
the following reads a file one byte at a time use the output method of mscomm to send it.
i dont have a modem or serial loopback hence cant test it. but you may need to convert the byte to a byte array and send it
Private Sub Command1_Click()
    Dim mybyte As Byte
    Dim myvariant
    Dim myfilelen As Long
    myfilelen = filelen("c:\1.bmp")
    Open "c:\1.bmp" For Binary As #1
    Dim i As Long
    For i = 1 To myfilelen
        Get #1, , mybyte
        myvariant = mybyte
        MSComm1.Output myvariant
        DoEvents
    Next
    Close #1
End Sub
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question