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
Solved

Putting Binary files into a Variable

Posted on 2000-02-23
7
161 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 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Suggested Solutions

Title # Comments Views Activity
How does CurrentUser work? 10 38
Bartender Integration Builder 3 44
which modules are active in VB6 project? 6 39
VBA: loop recent folder and copy txt file. 8 33
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 purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

791 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