Solved

Putting Binary files into a Variable

Posted on 2000-02-23
7
162 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 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
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!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

730 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