leftb, rightb, midb conversions?

S

Steve Ricketts

I'm converting a VB6 application to VB.net. In the program it deals with
audio data, stored as a variant, and uses rightb, leftb, and midb. Since
there are no equivalents in VB.net for those functions, are there any
examples of how you do the same thing with a user function or anything else?

Thanks,

Steve
 
A

Armin Zingler

Steve said:
I'm converting a VB6 application to VB.net. In the program it deals with
audio data, stored as a variant, and uses rightb, leftb, and midb. Since
there are no equivalents in VB.net for those functions, are there any
examples of how you do the same thing with a user function or anything else?


Do not use a String as a buffer for these operations. Probably an Array better
suits your needs.
 
S

Steve Ricketts

Thanks for your response. So, you're recommending that I just use a byte
array in every location where I've had a variant and then process the byte
array as necessary?

One of the uses is in an event routine that's fired from a 3rd party ActiveX
control that returns a variant data type:

private sub AudCodec1_FrameEvent(byval eventSender as system.object, byval
eventArgs as axAVPhone3.__AudCodec_FrameEvent) handles AudCodec1.FrameEvent

'UPGRADE WARNING: Couldn't resolve default property of object Data
recAudio = eventArgs.data

If recAudio is a byte array, is VB.net going to yell at me if I put the
eventArgs.data into it?

Thanks again for the response!
 
A

Armin Zingler

Steve said:
Thanks for your response. So, you're recommending that I just use a byte
array in every location where I've had a variant and then process the byte
array as necessary?

Depends on the data you are processing. Audio data often fits into an array of this structure:

structure Sample
public left as short
public right as short
end structure

One of the uses is in an event routine that's fired from a 3rd party ActiveX
control that returns a variant data type:

private sub AudCodec1_FrameEvent(byval eventSender as system.object, byval
eventArgs as axAVPhone3.__AudCodec_FrameEvent) handles AudCodec1.FrameEvent

'UPGRADE WARNING: Couldn't resolve default property of object Data
recAudio = eventArgs.data

If recAudio is a byte array, is VB.net going to yell at me if I put the
eventArgs.data into it?

As long as you don't turn Option Strict On, you are able to assign almost
everything to everything - but it can crash at runtime. But I suggest it's the
last thing to do after upgrading.

If you don't know the type of eventArgs.data you can try this:

dim o as object = eventargs.data
msgbox (o.gettype.fullname)

What does the msgbox say?
 
S

Steve Ricketts

Basically, I've been processing the audio data (variant) as a sequence of
individual bytes.

sub AudCap1_Frame(vData as variant)
dim bt() as byte

bt = vData

So I just assumed a byte array would be a good replacement. Thanks for
putting up with dumb newbie questions.

sr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top