Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Putting Binary files into a Variable

Posted on 2000-02-23
7
Medium Priority
?
168 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses

610 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