Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1

    [VB6] Caricare un suono

    E' possibile con vb6 fare in modo che se uno digiti in un campo un numero quando l'avvii chiami un suono????

    Ess.:

    Io digito: 3256874

    con 3 carica la suoneria 3.mp3
    con 4 carica la suoneria 4.mp3
    con 5 carica la suoneria 5.mp3
    ...




    Grazie per il vostro aiuto.

  2. #2
    Utente di HTML.it L'avatar di JamesD
    Registrato dal
    Oct 2001
    Messaggi
    415
    Per suonare dei suoni (che brutto italiano) esistono vari modi.
    Per esempio per suonare un mp3 esiste un ocx, oppure li puoi suonare con la shell tramite winamp (penso) o con la shellexecute! Per suonare file wav esiste un' API:

    codice:
    Declare Function sndPlaySound& Lib "winmm.dll" Alias "sndPlaySoundA" 
    (ByVal lpszSoundName$, ByVal uFlags&)
    Non so se per suonare gli mp3 esista un'API!

    Beh per fare quello che vuoi tu, se per campo intendi una textbox, puoi intercettare l'evento keypress che ti restituisce il codice ascii del carattere che hai inserito, e puoi eseguire le istruzioni che vuoi in base al tasto schiacciato (come riprodurre un suono)

  3. #3
    Essendo che mi trovo alle prima armi non puoi dirmi come utilizzare quel codice????

    Grazie.

  4. #4
    Utente di HTML.it L'avatar di JamesD
    Registrato dal
    Oct 2001
    Messaggi
    415
    Matti all'interno di un modulo la dichiarazione che ti ho postato precedentemente!

    Dopodichè per suonare un file (che deve essere in formato wav) devi semplicemente usare la funzione

    codice:
        sndPlaySound "PercorsoFile", snd_async
    Col secondo parametro così settato puoi mettere in coda più file da suonare!

    Se invece ti interessa un ocx (un pò vecchiotto) per suonare gli mp3 mi puoi mandare la tua email che te lo mando!


  5. #5
    Grazie per la tua risposta sei stato molto gentile.


    Se invece ti interessa un ocx (un pò vecchiotto) per suonare gli mp3 mi puoi mandare la tua email che te lo mando!
    No grazie, va benissimo il *.wav per quello che devo fare.

  6. #6
    Non funziona


    codice:
    Compiler error:
    
    Expected: line number or label or statement or end of statement

  7. #7
    Utente di HTML.it L'avatar di Markooo
    Registrato dal
    Mar 2003
    Messaggi
    247
    Metti in un form:

    codice:
    Private Const SND_APPLICATION = &H80         '  look for application specific association
    Private Const SND_ALIAS = &H10000     '  name is a WIN.INI [sounds] entry
    Private Const SND_ALIAS_ID = &H110000    '  name is a WIN.INI [sounds] entry identifier
    Private Const SND_ASYNC = &H1         '  play asynchronously
    Private Const SND_FILENAME = &H20000     '  name is a file name
    Private Const SND_LOOP = &H8         '  loop the sound until next sndPlaySound
    Private Const SND_MEMORY = &H4         '  lpszSoundName points to a memory file
    Private Const SND_NODEFAULT = &H2         '  silence not default, if sound not found
    Private Const SND_NOSTOP = &H10        '  don't stop any currently playing sound
    Private Const SND_NOWAIT = &H2000      '  don't wait if the driver is busy
    Private Const SND_PURGE = &H40               '  purge non-static events for task
    Private Const SND_RESOURCE = &H40004     '  name is a resource name or atom
    Private Const SND_SYNC = &H0         '  play synchronously (default)
    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    
    Private Sub Command1_Click()
       PlaySound "metti qui il percorso del file.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    End Sub
    Non saprei

  8. #8
    Funziona grazie

    Ma ho notato che non accoda i comandi perkè io devo fare una cosa del genere

    codice:
    If Text1 = 1 Then PlaySound "c:\corsovb6\inizio.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    If Text1 = 2 Then PlaySound "c:\corsovb6\inizio.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    If Text1 = 3 Then PlaySound "c:\corsovb6\inizio.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    If Text2 = 1 Then PlaySound "c:\corsovb6\fine.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    If Text2 = 2 Then PlaySound "c:\corsovb6\fine.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    If Text2 = 3 Then PlaySound "c:\corsovb6\fine.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    ...
    scusatemi se rompo tanto

  9. #9
    Utente di HTML.it L'avatar di Markooo
    Registrato dal
    Mar 2003
    Messaggi
    247
    Devi mettere tutto nell'evento KeyDown delle textbox:

    codice:
    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKey1 Or vbKeyNumpad1 Then PlaySound "c:\corsovb6   \inizio.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    If KeyCode = vbKey2 Or vbKeyNumpad2 Then PlaySound "c:\corsovb6\inizio.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    If KeyCode = vbKey3 Or vbKeyNumpad3 Then PlaySound "c:\corsovb6   \inizio.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    End Sub
    codice:
    Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKey1 Or vbKeyNumpad1 Then PlaySound "c:\corsovb6   \fine.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    If KeyCode = vbKey2 Or vbKeyNumpad2 Then PlaySound "c:\corsovb6\fine.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    If KeyCode = vbKey3 Or vbKeyNumpad3 Then PlaySound "c:\corsovb6   \fine.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    End Sub
    Ciao, fai sapere!
    Non saprei

  10. #10
    Altro esempio (Variante che utilizza 2 command_button)
    codice:
    'In un MODULO
    
    Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
        Public Const SND_ASYNC = &H1
        Public Const SND_SYNC = &H0
        Public Const SND_LOOP = &H8
    
    
    
    'In un FORM
    
    Option Explicit
        Dim S As Long
    
    Private Sub Command1_Click()
        S = sndPlaySound("C:\Documenti\uno.wav", SND_ASYNC)
    End Sub
     
    Private Sub Command2_Click()
        S = sndPlaySound("C:\Documenti\due.wav", SND_ASYNC)
    End Sub
    P.S. con un textbox sarebbe così:
    codice:
    'Codice del FORM
    
    Option Explicit
        Dim S As Long
    
    Private Sub Text_Change()
            
        If Text <> "" Then
            
            If Text = 1 Then
                S = sndPlaySound("C:\Documenti\uno.wav", SND_ASYNC)
            ElseIf Text = 2 Then
                S = sndPlaySound("C:\Documenti\due.wav", SND_ASYNC)
            Else
                ' ALTRO FILE .WAV
            End If
            
        End If
    
    End Sub
    ...Terrible warlords, good warlords, and an english song

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.