Solved

convert binary to text(modem)

Posted on 2002-06-19
3
196 Views
Last Modified: 2012-06-27
I'm able to send data thru modem using cominputmodebinary

Dim aryBytes() As Byte
aryBytes = Text1.Text
MSComm1.Output aryBytes

but all i get at the other end are questionmarks.

inbuff= mscomm1.input
msgbox inbuff

even if i dim inbuff as byte the same thing happens.Help! how do i convert the input data to text?
0
Comment
Question by:sudeepn
3 Comments
 
LVL 6

Expert Comment

by:Nitin Sontakke
ID: 7092287
I am probably the last person who should post a comment to this but still....

A simple assignment like this won't work. You will need to assign the byte value of each and every character in text1.text. If i am correct, you can do it as follows:

Dim aryBytes() As Byte, intIndex as Integer
Redim aryBytes(Len(Text1.Text))
For intIndex = 1 to Len(Text1.Text)
    aryBytes(intIndex) = CByte(Asc(Mid(Text1.Text, intIndex, 1)))
Next intIndex
MSComm1.Output aryBytes

Again, just Asc() is enough, to achieve it? I don't see any work done by cByte() above.

0
 
LVL 5

Expert Comment

by:Julian_K
ID: 7092289
Hi.
1. Why sending as aryBytes? I mean why do you send data as bytes? Why not send it as string?

2. Have you tried with the "StrConv" function to convert the data from string to binary and vice versa?
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 50 total points
ID: 7092755
Yes, use StrConv.

The problem is that the buffer will contain single byte data, which needs to be converted to unicode data for VB to display it properly.

Dim buffer
buffer = oCommMiu.Input
If Len(buffer) > 0 Then
  strConnect = strConnect & StrConv(buffer, vbUnicode)
End if
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

939 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

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now