Mình định làm cái game bằng powerpoint cho tụi nhỏ chơi, tìm trên mạng thì down đc cái code trúc xanh bên voz nhưng giờ mình muốn chèn âm thanh vào game mà loay hoay từ sáng h không chèn đc. Mình muốn là khi chọn đúng 2 cặp hình thì nó hô "Đúng rồi", sai thì nó hô "Sai rồi", end game thì hô "Trò chơi kết thúc" đại loại vậy, mấy bạn chỉ mình cái code thôi được rồi còn âm thanh thì mình tự tìm. Đây là cái file mình down bên Voz: View attachment test_truc_xanh.rar Bạn nào rành về code VB thì giúp mình với, cám ơn các bạn nhiều.
[Spoil] Mã: Public nClickIndex, nFirstIndex, nSecondIndex As Integer Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long Dim ret As Long Private Sub Compare(ByVal nFirstIndex As Integer, ByVal nSecondIndex As Integer) Select Case nFirstIndex ' Close first clicked image Case 1 Label1.Visible = True Image1.Visible = False Case 2 Label2.Visible = True Image2.Visible = False Case 3 Label3.Visible = True Image3.Visible = False Case 4 Label4.Visible = True Image4.Visible = False Case 5 Label5.Visible = True Image5.Visible = False Case 6 Label6.Visible = True Image6.Visible = False Case 7 Label7.Visible = True Image7.Visible = False Case 8 Label8.Visible = True Image8.Visible = False End Select Select Case nSecondIndex ' Close second clicked image Case 1 Label1.Visible = True Image1.Visible = False Case 2 Label2.Visible = True Image2.Visible = False Case 3 Label3.Visible = True Image3.Visible = False Case 4 Label4.Visible = True Image4.Visible = False Case 5 Label5.Visible = True Image5.Visible = False Case 6 Label6.Visible = True Image6.Visible = False Case 7 Label7.Visible = True Image7.Visible = False Case 8 Label8.Visible = True Image8.Visible = False End Select If (nFirstIndex * nSecondIndex = 5) Then ' 1 vs 5 Label1.Visible = False Label5.Visible = False Image1.Visible = False Image5.Visible = False End If If (nFirstIndex * nSecondIndex = 16) Then ' 2 vs 8 Label2.Visible = False Label8.Visible = False Image2.Visible = False Image8.Visible = False End If If (nFirstIndex * nSecondIndex = 18) Then ' 3 vs 6 Label3.Visible = False Label6.Visible = False Image3.Visible = False Image6.Visible = False End If If (nFirstIndex * nSecondIndex = 28) Then ' 4 vs 7 Label4.Visible = False Label7.Visible = False Image4.Visible = False Image7.Visible = False End If If (Label1.Visible = False) And (Label2.Visible = False) And (Label3.Visible = False) And (Label4.Visible = False) _ And (Label5.Visible = False) And (Label6.Visible = False) And (Label7.Visible = False) And (Label8.Visible = False) Then ' Game Over Label9.Visible = True End If End Sub Private Sub Pause(ByVal nSecond As Single) Dim t0 As Single Dim dummy As Integer t0 = Timer Do While Timer - t0 < nSecond dummy = DoEvents() If Timer < t0 Then t0 = t0 - 86400 End If Loop End Sub Private Sub AfterClick(ByVal nIndex As Integer) If nClickIndex = 1 Then nFirstIndex = nIndex Else nSecondIndex = nIndex Call Pause(1) Call Compare(nFirstIndex, nSecondIndex) End If End Sub Private Sub Command1_Click() ret = mciSendString("play C:\a.wav Type waveaudio", 0&, 0, 0) End Sub Private Sub Label1_Click() Label1.Visible = False Image1.Visible = True nClickIndex = 3 - nClickIndex ' If n = 2 then n = 1 (first click), else n = 2 (second click) Call AfterClick(1) End Sub Private Sub Label2_Click() Label2.Visible = False Image2.Visible = True nClickIndex = 3 - nClickIndex ' If n = 2 then n = 1 (first click), else n = 2 (second click) Call AfterClick(2) End Sub Private Sub Label3_Click() Label3.Visible = False Image3.Visible = True nClickIndex = 3 - nClickIndex ' If n = 2 then n = 1 (first click), else n = 2 (second click) Call AfterClick(3) End Sub Private Sub Label4_Click() Label4.Visible = False Image4.Visible = True nClickIndex = 3 - nClickIndex ' If n = 2 then n = 1 (first click), else n = 2 (second click) Call AfterClick(4) End Sub Private Sub Label5_Click() Label5.Visible = False Image5.Visible = True nClickIndex = 3 - nClickIndex ' If n = 2 then n = 1 (first click), else n = 2 (second click) Call AfterClick(5) End Sub Private Sub Label6_Click() Label6.Visible = False Image6.Visible = True nClickIndex = 3 - nClickIndex ' If n = 2 then n = 1 (first click), else n = 2 (second click) Call AfterClick(6) End Sub Private Sub Label7_Click() Label7.Visible = False Image7.Visible = True nClickIndex = 3 - nClickIndex ' If n = 2 then n = 1 (first click), else n = 2 (second click) Call AfterClick(7) End Sub Private Sub Label8_Click() Label8.Visible = False Image8.Visible = True nClickIndex = 3 - nClickIndex ' If n = 2 then n = 1 (first click), else n = 2 (second click) Call AfterClick(8) End Sub Private Sub Start_Click() ret = mciSendString("play C:\a.wav Type waveaudio", 0&, 0, 0) nClickIndex = 2 Label1.Visible = True Image1.Visible = False Label2.Visible = True Image2.Visible = False Label3.Visible = True Image3.Visible = False Label4.Visible = True Image4.Visible = False Label5.Visible = True Image5.Visible = False Label6.Visible = True Image6.Visible = False Label7.Visible = True Image7.Visible = False Label8.Visible = True Image8.Visible = False Label9.Visible = False End Sub [/Spoil] Đây là code mình copy ra các bạn rảnh thỉ xem thử giúp mình với.
code đó thì không bị lỗi gì, ý mình muốn là chèn âm thanh vào đoạn code đó thì chèn như thế nào? Ví dụ: lúc lật 2 hình đúng thì nó kêu "đúng rồi". Cám ơn bạn đã xem qua.