Jeff Posted July 8, 2010 Author Share Posted July 8, 2010 Here is the script I put in:```Private Sub Purchasbutton_Click() Dim Buying As String Buying = SelectAnItem.Text Select Case Buying Case "Sugar" If inv1.Caption = "Empty" And Money >= 1 Then inv1.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of sugar." ElseIf inv2.Caption = "Empty" And Money >= 1 Then inv1.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of sugar." Else If Money < 1 Then Newsfeed.AddItem "You don't have enough doubloons to buy that!" Else Newsfeed.AddItem "You need more cargospace to buy that!" End If Case Else inv1.Caption = "fail" End SelectEnd Sub```And when I run it, I get> Compile error: Case else outside Select CaseIf I take out the case else, I still run into problems. Anyone have any suggestions on how to fix it? Or why it is breaking?–-------Edit-----------------Now I just go to the debugging screen whenever I put this code in:```Private Sub Purchasbutton_Click() Dim Buying As String Buying = SelectAnItem.Text Select Case Buying Case "Sugar" If inv1.Caption = "Empty" And Money >= 1 Then inv1.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv2.Caption = "Empty" And Money >= 1 Then inv2.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv3.Caption = "Empty" And Money >= 1 Then inv3.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv4.Caption = "Empty" And Money >= 1 Then inv4.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv5.Caption = "Empty" And Money >= 1 Then inv5.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv6.Caption = "Empty" And Money >= 1 Then inv6.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv7.Caption = "Empty" And Money >= 1 Then inv7.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv8.Caption = "Empty" And Money >= 1 Then inv8.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv9.Caption = "Empty" And Money >= 1 Then inv9.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv10.Caption = "Empty" And Money >= 1 Then inv10.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv11.Caption = "Empty" And Money >= 1 Then inv11.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv12.Caption = "Empty" And Money >= 1 Then inv12.Caption = Buying Money = Money - 1 Else If Money < 1 Then Newsfeed.AddItem "You don't have enough doubloons to buy that!" Else Newsfeed.AddItem "You need more cargospace to buy that!" End If End If Case "Coffee" If inv1.Caption = "Empty" And Money >= 1 Then inv1.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv2.Caption = "Empty" And Money >= 1 Then inv2.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv3.Caption = "Empty" And Money >= 1 Then inv3.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv4.Caption = "Empty" And Money >= 1 Then inv4.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv5.Caption = "Empty" And Money >= 1 Then inv5.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv6.Caption = "Empty" And Money >= 1 Then inv6.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv7.Caption = "Empty" And Money >= 1 Then inv7.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv8.Caption = "Empty" And Money >= 1 Then inv8.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv9.Caption = "Empty" And Money >= 1 Then inv9.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv10.Caption = "Empty" And Money >= 1 Then inv10.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv11.Caption = "Empty" And Money >= 1 Then inv11.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv12.Caption = "Empty" And Money >= 1 Then inv12.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying Else If Money < 1 Then Newsfeed.AddItem "You don't have enough doubloons to buy that!" Else Newsfeed.AddItem "You need more cargospace to buy that!" End If End If Case "Tobbacco" If inv1.Caption = "Empty" And Money >= 1 Then inv1.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv2.Caption = "Empty" And Money >= 1 Then inv2.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv3.Caption = "Empty" And Money >= 1 Then inv3.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv4.Caption = "Empty" And Money >= 1 Then inv4.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv5.Caption = "Empty" And Money >= 1 Then inv5.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv6.Caption = "Empty" And Money >= 1 Then inv6.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv7.Caption = "Empty" And Money >= 1 Then inv7.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv8.Caption = "Empty" And Money >= 1 Then inv8.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv9.Caption = "Empty" And Money >= 1 Then inv9.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv10.Caption = "Empty" And Money >= 1 Then inv10.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv11.Caption = "Empty" And Money >= 1 Then inv11.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv12.Caption = "Empty" And Money >= 1 Then inv12.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying Else If Money < 1 Then Newsfeed.AddItem "You don't have enough doubloons to buy that!" Else Newsfeed.AddItem "You need more cargospace to buy that!" End If End IfCase "Cacao" If inv1.Caption = "Empty" And Money >= 1 Then inv1.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv2.Caption = "Empty" And Money >= 1 Then inv2.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv3.Caption = "Empty" And Money >= 1 Then inv3.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv4.Caption = "Empty" And Money >= 1 Then inv4.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv5.Caption = "Empty" And Money >= 1 Then inv5.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv6.Caption = "Empty" And Money >= 1 Then inv6.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv7.Caption = "Empty" And Money >= 1 Then inv7.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv8.Caption = "Empty" And Money >= 1 Then inv8.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv9.Caption = "Empty" And Money >= 1 Then inv9.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv10.Caption = "Empty" And Money >= 1 Then inv10.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv11.Caption = "Empty" And Money >= 1 Then inv11.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv12.Caption = "Empty" And Money >= 1 Then inv12.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying Else If Money < 1 Then Newsfeed.AddItem "You don't have enough doubloons to buy that!" Else Newsfeed.AddItem "You need more cargospace to buy that!" End If End IfCase "Gold" If inv1.Caption = "Empty" And Money >= 2 Then inv1.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv2.Caption = "Empty" And Money >= 2 Then inv2.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv3.Caption = "Empty" And Money >= 2 Then inv3.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv4.Caption = "Empty" And Money >= 1 Then inv4.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv5.Caption = "Empty" And Money >= 2 Then inv5.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv6.Caption = "Empty" And Money >= 2 Then inv6.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv7.Caption = "Empty" And Money >= 2 Then inv7.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv8.Caption = "Empty" And Money >= 2 Then inv8.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv9.Caption = "Empty" And Money >= 2 Then inv9.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv10.Caption = "Empty" And Money >= 2 Then inv10.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv11.Caption = "Empty" And Money >= 2 Then inv11.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv12.Caption = "Empty" And Money >= 2 Then inv12.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying Else If Money < 2 Then Newsfeed.AddItem "You don't have enough doubloons to buy that!" Else Newsfeed.AddItem "You need more cargospace to buy that!" End If End IfCase "Silver" If inv1.Caption = "Empty" And Money >= 2 Then inv1.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv2.Caption = "Empty" And Money >= 2 Then inv2.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv3.Caption = "Empty" And Money >= 2 Then inv3.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv4.Caption = "Empty" And Money >= 1 Then inv4.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv5.Caption = "Empty" And Money >= 2 Then inv5.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv6.Caption = "Empty" And Money >= 2 Then inv6.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv7.Caption = "Empty" And Money >= 2 Then inv7.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv8.Caption = "Empty" And Money >= 2 Then inv8.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv9.Caption = "Empty" And Money >= 2 Then inv9.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv10.Caption = "Empty" And Money >= 2 Then inv10.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv11.Caption = "Empty" And Money >= 2 Then inv11.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying ElseIf inv12.Caption = "Empty" And Money >= 2 Then inv12.Caption = Buying Money = Money - 2 Newsfeed.AddItem "You have succesfully bought a crate of " & Buying Else If Money < 2 Then Newsfeed.AddItem "You don't have enough doubloons to buy that!" Else Newsfeed.AddItem "You need more cargospace to buy that!" End If End If Case Else Newsfeed.AddItem "Error: Purchasing insuccessful." End SelectEnd Sub```I've gone over it a couple times, but can't seem to see whats wrong… Link to comment Share on other sites More sharing options...
Ruins of Hell Posted July 8, 2010 Share Posted July 8, 2010 Try:```Private Sub Purchasbutton_Click() Dim Buying As String Buying = SelectAnItem.Text Select Case Buying Case "Sugar" If inv1.Caption = "Empty" And Money >= 1 Then inv1.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of sugar." ElseIf inv2.Caption = "Empty" And Money >= 1 Then inv1.Caption = Buying Money = Money - 1 Newsfeed.AddItem "You have succesfully bought a crate of sugar." Else If Money < 1 Then Newsfeed.AddItem "You don't have enough doubloons to buy that!" Else Newsfeed.AddItem "You need more cargospace to buy that!" End If End If Case Else inv1.Caption = "fail" End SelectEnd Sub``` Link to comment Share on other sites More sharing options...
Jeff Posted July 8, 2010 Author Share Posted July 8, 2010 Thanks! works like a charm. I can't believe i missed that second end if. Link to comment Share on other sites More sharing options...
Jeff Posted July 12, 2010 Author Share Posted July 12, 2010 sorry for the double post, but I really need help with this still…--Edit--I closed vb6 and then openned it again and it worked fine. weird. Link to comment Share on other sites More sharing options...
guzmanm Posted July 12, 2010 Share Posted July 12, 2010 Haha, that's epic. Link to comment Share on other sites More sharing options...
Jeff Posted July 12, 2010 Author Share Posted July 12, 2010 What are you talking about lol? Link to comment Share on other sites More sharing options...
guzmanm Posted July 12, 2010 Share Posted July 12, 2010 @Jeff:> What are you talking about lol?You re-opened vb6 and all fixed, xD Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now