Results 1 to 19 of 19

Thread: HELP! NO WEBSITES

  1. #1

    Thread Starter
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702

    HELP! NO WEBSITES

    ok i want to make an WAV play when my program begins, i made it to a custom resource file, how do i make it play with the windll or rundll32, whatever that built in thing is! thanks

    PS! DONT TELL ME TO CHECK A WEBSITE, I NEED STEP BY STEP HELP
    Last edited by duc; Oct 23rd, 2002 at 07:36 PM.

  2. #2

    Thread Starter
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702
    this is what i have
    VB Code:
    1. Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    2.  
    3. Private Const SND_ASYNC = &H1 ' Play asynchronously
    4.  
    5. Private Const SND_NODEFAULT = &H2 ' Don't use default sound
    6.  
    7. Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
    8.  
    9. 'Usage: PlayWavResource ResourceID
    10. 'Example: Call PlayWavResource(101)
    11.  
    12. Dim retVal As Long
    13. Dim SoundBuffer As String
    14. SoundBuffer = StrConv(LoadResData(pint101, "CUSTOM"), vbUnicode)
    15. retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
    16.  
    17. End Sub

    and it says Invalid Outside Procedure and highlightd pint101

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Every command carried out by VB must be in a sub, function, or property. Only declarations can be outside of them.
    VB Code:
    1. Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    2.  
    3. Private Const SND_ASYNC = &H1 ' Play asynchronously
    4.  
    5. Private Const SND_NODEFAULT = &H2 ' Don't use default sound
    6.  
    7. Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
    8.  
    9. 'Usage: PlayWavResource ResourceID
    10. 'Example: Call PlayWavResource(101)
    11.  
    12. Private Sub PlayASound()
    13. Dim retVal As Long
    14. Dim SoundBuffer As String
    15. SoundBuffer = StrConv(LoadResData(pint101, "CUSTOM"), vbUnicode)
    16. retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
    17.  
    18. End Sub
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4

    Thread Starter
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702
    cool that works, how do i make it play now when the form opens

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Just call PlayASound in the Form_Load, or Form_Activate event.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  6. #6
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Put the code in the form_load event...
    <removed by admin>

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    If you would have posted this code in your other thread, Duc, you would have gotten help much faster.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8

    Thread Starter
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702
    wait wait, slow down. okay i have the first code in there. now what exactly do i put where to make it play when the prog begins. the res file is named 101

  9. #9
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    VB Code:
    1. Private Sub Form_Load()
    2.   PlayASound
    3. End Sub
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    VB Code:
    1. Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    2. Private Const SND_ASYNC = &H1 ' Play asynchronously
    3. Private Const SND_NODEFAULT = &H2 ' Don't use default sound
    4. Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
    5.  
    6. Private Sub Form_Load()
    7. 'Usage: PlayWavResource ResourceID
    8. 'Example: Call PlayWavResource(101)
    9.  
    10. Dim retVal As Long
    11. Dim SoundBuffer As String
    12. SoundBuffer = StrConv(LoadResData(101, "CUSTOM"), vbUnicode)
    13. retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
    14.  
    15. End Sub
    <removed by admin>

  11. #11

    Thread Starter
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702
    Private Sub Form_Load()
    PlayASound
    End Sub


    will play it? dont need to identify it? cool!

  12. #12

    Thread Starter
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702
    it says Resource with identifier 0 not found

    VB Code:
    1. Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    2.  
    3. Private Const SND_ASYNC = &H1 ' Play asynchronously
    4.  
    5. Private Const SND_NODEFAULT = &H2 ' Don't use default sound
    6.  
    7. Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
    8.  
    9. 'Usage: PlayWavResource ResourceID
    10. 'Example: Call PlayWavResource(101)
    11.  
    12. Private Sub PlayASound()
    13. Dim retVal As Long
    14. Dim SoundBuffer As String
    15. SoundBuffer = StrConv(LoadResData(pint101, "CUSTOM"), vbUnicode)
    16. retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
    17.  
    18. End Sub
    19.  
    20.  
    21.  
    22.  
    23. Private Sub Form_Load()
    24.   PlayASound
    25. End Sub

  13. #13

    Thread Starter
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702
    HOLY FLUNKING TOADS I GOT IT TO Werk

  14. #14

    Thread Starter
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702
    no wait....i have
    VB Code:
    1. Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    2. Private Const SND_ASYNC = &H1 ' Play asynchronously
    3. Private Const SND_NODEFAULT = &H2 ' Don't use default sound
    4. Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
    5.  
    6. Private Sub Form_Load()
    7. 'Usage: PlayWavResource ResourceID
    8. 'Example: Call PlayWavResource(101)
    9.  
    10. Dim retVal As Long
    11. Dim SoundBuffer As String
    12. SoundBuffer = StrConv(LoadResData(101, "CUSTOM"), vbUnicode)
    13. retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
    14.  
    15.  
    16.  
    17. End Sub
    18.  
    19.  
    20. Private Sub about_Click()
    21. shouts.Show
    22. End Sub
    23.  
    24. Private Sub area51_Click()
    25. area.Show
    26. End Sub
    27.  
    28.  
    29.  
    30. Private Sub close_Click()
    31.  
    32. Unload Me
    33.  
    34. End Sub
    35.  
    36.  
    37.  
    38. Private Sub gett_Click()
    39.  
    40. Shell "explorer [url]http://www.streamaudio.com/stations/player/pages/register1.asp?[/url]"
    41.  
    42. End Sub
    43.  
    44. Private Sub killed_Click()
    45. aim.Show
    46. End Sub
    47.  
    48. Private Sub link_Click()
    49.  
    50. Shell "explorer [url]http://www.schenectadychristian.org[/url]"
    51.  
    52.  
    53. End Sub
    54.  
    55. Private Sub off_Click()
    56.  
    57. Timer1.Enabled = False
    58. Timer2.Enabled = False
    59.  
    60. End Sub
    61.  
    62. Private Sub on_Click()
    63.  
    64. Timer1.Enabled = True
    65. Timer2.Enabled = True
    66.  
    67. End Sub
    68.  
    69. Private Sub Timer1_Timer()
    70.  
    71. Me.Left = Me.Left - 10
    72. Timer1.Enabled = False
    73. Timer2.Enabled = True
    74.  
    75.  
    76. End Sub
    77.  
    78. Private Sub Timer2_Timer()
    79. Me.Left = Me.Left + 10
    80. Timer2.Enabled = False
    81. Timer1.Enabled = True
    82.  
    83.  
    84. End Sub



    Where do i put the PlayASound thing

  15. #15
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by duc

    Where do i put the PlayASound thing
    You don't need it with the approach you're taking.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  16. #16

    Thread Starter
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702
    now that i figured it out, can i make it loop?
    Last edited by duc; Oct 23rd, 2002 at 08:24 PM.

  17. #17

    Thread Starter
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702
    like i want the sound to keep repeating. should i use a timer or what? sorry for not editing

  18. #18
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Originally posted by duc
    like i want the sound to keep repeating. should i use a timer or what? sorry for not editing
    Just plop the code that is in the form_load event in a timer event instead.
    <removed by admin>

  19. #19
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by MidgetsBro
    Just plop the code that is in the form_load event in a timer event instead.
    Then he'd have to time the timer perfectly to match the end of the song/sound bite.

    Try adding this constant:

    VB Code:
    1. Private Const SND_LOOP = &H8

    and replace this line as follows:

    VB Code:
    1. 'replace:
    2. retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
    3.  
    4. 'with:
    5. retVal = sndPlaySound(SoundBuffer, SND_LOOP Or SND_NODEFAULT Or SND_MEMORY)

    I haven't tested it, so I'm not sure if it'll work.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width