Solved

convert binary to text(modem)

Posted on 2002-06-19
3
195 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

757 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

21 Experts available now in Live!

Get 1:1 Help Now