Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating juke box in vb

Status
Not open for further replies.

Dhr003

Programmer
Nov 27, 2001
8
GB
ppl im new here and a beginner in vb programming, im working on a vb project to design a juke box which plays a number of songs whhich is dependent on the money u enter. for example if £0.50p is enter 1 song is selected or if £1.00 is entered 3 is selected and displayed on a textbox etc. Ive started the coding but am stuck on a problem. when i enter money it should only let me select the number of songs allowed to but it doesnt it lets me keep on selecting without no error message coming up. ill paste my coding here( it isnt finished its done up to the point where im stuck) so ppl plz correct me where im goign wrong.
-----------------------------------------------------------------------------------------------------------------------------------
Private Sub cmbSong_Click()

If cmbSong.Text = "1" Then
txtsongName = "Stan"
Me.txtartistname = "Eminem"
ElseIf cmbSong.Text = "2" Then
txtsongName = "Krishna"
Me.txtartistname = "Dido"
ElseIf cmbSong.Text = "3" Then
txtsongName = "Thriller"
Me.txtartistname = "Michael Jackson"
ElseIf cmbSong.Text = "4" Then
txtsongName = "Slave 2 u"
Me.txtartistname = "Britney Spears"
ElseIf cmbSong.Text = "5" Then
txtsongName = "Lavida loka"
Me.txtartistname = "Ricky Martin"
End If

End Sub

Private Sub cmdcl_Click()
txtcount.Text = " "
End Sub

Private Sub cmdConfirm_Click()
If Text3.Text = "0:50" Then
MsgBox "Select 1 Songs & Please Press Proceed...Thankyou"
Else
If Text3.Text = "1:00" Then
MsgBox "Select 3 Songs & Please Press Proceed...Thankyou"
'Else
'If Text3.Text = "1:50" Then
'MsgBox "Please Press Enter to Proceed...Thankyou"
Else
If Text3.Text = "2:00" Then
MsgBox "Select 8 Songs & Please Press Proceed...Thankyou"
Else
MsgBox "You Have Entered The Wrong Amount!!!", vbCritical
MsgBox "Please enter according to Pricing show opposite..", vbInformation
Text3.Text = " "
End If
'End If
End If
End If
End Sub

Private Sub cmdplay_Click()
Beep
Beep
Image1.Visible = True
End Sub

Private Sub cmdproceed_Click()
Me.frmSongDetails.Visible = True
End Sub

Private Sub cmdSelectSong_Click()

Dim songName As String
Dim artistName As String
Dim counter As Integer
Dim songcount As Integer
Dim i As Integer

If Text3.Text = "0:50" Then
counter = 1
ElseIf Text3.Text = "1:00" Then
counter = 3
ElseIf Text3.Text = "2:00" Then
counter = 8
End If


Select Case counter

Case 1
songName = Me.txtsongName.Text
artistName = Me.txtartistname.Text
txtsonglist.Text = songName & vbCrLf & artistName
Case 3
counter = 0
songName = Me.txtsongName.Text
artistName = Me.txtartistname.Text
txtsonglist.Text = songName & vbCrLf & artistName
Case 8
counter = 0
songName = Me.txtsongName.Text
artistName = Me.txtartistname.Text
txtsonglist.Text = songName & vbCrLf & artistName
Case Else
MsgBox "ERROR", vbCritical
'txtartistname.Text = artistName
End Select

End Sub

Private Sub cmdstart_Click()
Me.frmMoney.Visible = True
End Sub

Private Sub Command1_Click(Index As Integer)
Let Text3.Text = Text3.Text & Format(Index, "0")

If Len(Text3.Text) = 1 Then
Let Text3.Text = Text3.Text & ":"
If Len(Text3.Text) >= 201 Then
MsgBox " you have entered too much"
Let Text3.Text = ""
End If
End If
End Sub

Private Sub Command2_Click()

'frmMoney.Visible = True
End Sub

Private Sub Command3_Click()
Text3.Text = " "
End Sub

Private Sub Form_Load()

MsgBox "Welcome!", vbInformation, "JukeBox Selector"
' settings for combo box initialisation values
cmbSong.AddItem "1"
cmbSong.AddItem "2"
cmbSong.AddItem "3"
cmbSong.AddItem "4"
cmbSong.AddItem "5"

End Sub

Private Sub quit_Click()

End
End Sub


Public Sub addsongtext(number As Integer)

End Sub
 
Have a look at the ItemCheck event of the listbox. You should be able to put some code in here to diable the listbox once the number of items selected is greater than x where x is a form level variable you set to equal the maximum number of selections dependant upon the money input.

Also bear in mind that the listbox.selected array should tell you how many items are selected.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top