?
Solved

Putting Binary files into a Variable

Posted on 2000-02-23
7
Medium Priority
?
166 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
[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
7 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 2552845
0
 
LVL 28

Accepted Solution

by:
Ark earned 200 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

777 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