Jump to content

How do you play music in a Visual Basic 4.0 Program

Featured Replies

I have looked in the help guide in Visual Basic and Learn Visual Basic 4.0 in 21 Days and cannot find a way to set off code to play a .wav file besides the default BEEP.

Visual Basic 4.0 :o Welcome to the 90s!!

 

(this goes in a module)

 

Option Explicit

 

Public Declare Function sndPlaySound Lib "winmm.dll" Alias _

"sndPlaySoundA" (ByVal lpszSoundName As String, _

ByVal uFlags As Long) As Long

Const SND_SYNC = &H0

Const SND_ASYNC = &H1

Const SND_NODEFAULT = &H2

Const SND_LOOP = &H8

Const SND_NOSTOP = &H10

 

'then, when you want to play a wav

Dim sFlags As Long

sFlags = SND_ASYNC Or SND_NODEFAULT

sndPlaySound "FileName.Wav", sFlags

 

 

from here

  • Author

I tried the code but VB says that SND_ASYNC is an "Invalid Outside Procedure. If I delete it it says the same for SND_NODEFAULT.

I copied and pasted the code right from the site you gave me.

"Dim sFlags As Long

sFlags = SND_ASYNC Or SND_NODEFAULT

sndPlaySound "FileName.Wav", sFlags"

 

Where did you put that part? It shouldn't be in the declarations part of a module, it should be where you want the action performed..

  • Author

I tried placing the code you last posted in a Command Button and it still doesn't work. When I run it it does nothing.

:confused::):confused:

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.