Solved

Putting Binary files into a Variable

Posted on 2000-02-23
7
158 Views
Last Modified: 2013-11-13
Can anyone help with this?

Consider the following:
I am recording a WAV file
and then sending it to a remote
user through a winsock control.

How can I get that ENTIRE
WAV file into a variable
so I can send it, and it
doesn't get truncated?

BTW: This code doesn't work:

-=SNIP=-

Dim a as byte

Open app.path & "\test.wav"
     Get #1, , a
Close #1

-=SNIP=-

[Nor does it work with an byte array]

'a' does not equal the file!
It either is missing or has more data!

HELP!!
0
Comment
Question by:tsa2
7 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 2552845
0
 
LVL 27

Accepted Solution

by:
Ark earned 50 total points
ID: 2552874
Hi
Dim a() As Byte
Open "c:\autoexec.bat" For Binary As #1
ReDim a(LOF(1))
Get #1, , a
Close #1

Or

Dim a as String
Open "c:\autoexec.bat" For Binary As #1
a = String((LOF(1)), " ")
Get #1, , a
Close #1

Cheers
0
 
LVL 3

Expert Comment

by:Gordonp
ID: 2553596
Try this :

Dim ByData() as Byte
Dim nFilenum As Integer
nFilenum = FreeFile
   
Open sFilename For Binary Access Read As nFilenum
   
ReDim ByData(FileLen(sFilename))
Get #nFilenum, , ByData()
Close nFilenum


I have been using this code in various apps, also for reading in Wav files, but for a different purpose, to read into direct Sound buffers.

Gordon
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 27

Expert Comment

by:Ark
ID: 2553639
Hi, Gordon
Look at my code above. Why don't I check another radio button ;-))

Cheers
0
 
LVL 3

Expert Comment

by:Gordonp
ID: 2553656
Sorry,
       but your comment wasnt displayed when I answered the question. I'll gracefully withdraw my answer anyway.

Gordon
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2554047
There are two projects on your Visual Basic CD that do wav audio streaming... You may want to take a look at them.

They are in:

 \TOOLS\UNSUPPRT\VOICE\VCHATAPP

     - and -

 \TOOLS\UNSUPPRT\VOICE\WAVESTRM


Hope this helps!


Cheers!
0
 

Author Comment

by:tsa2
ID: 2575499
Answered my question.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

708 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

15 Experts available now in Live!

Get 1:1 Help Now