I am currently writing a game in Visual Basic 6. It is a role-playing game that has many real-life features, like buying shops, cars, houses, and also joining a gang.
I need help with something. On the main GUI, which has options for a job, like a shop owner, a hitman, a taxi driver, etc., when you select the job that you wish to join, it opens a form, frmJobInfo, which has a textbox , txtInfo, with the information about the job in it. Now, say the user hasn't purchased a shop yet, and they click "Shop Owner," it says "You can't become a shop owner, you don't own a shop." But, if the user has purchased a shop, then frmJobInfo opens with info on the shop, income, and an hourly/monthly payment. I also added a combobox on frmJobInfo, that displays the shops that you own.

Now, if you own more than one shop, then it displays all of them in the combobox. What I don't understand, is that I used an array to hold the shops that you own, MyShops[10]. In my combobox, I want to use this:

Private Sub cmdShopOwner_Click()
If OwnShop = True Then
    SelectedJob = "ShopOwner"
    frmJobInfo!fraInfo.Caption = "Job: Shop Owner"
    frmJobInfo!txtInfo.Text = "You selected the job 'Shop Owner'"
    frmJobInfo!cboShops.Text = "Select A Shop To Own:"
[B]    frmJobInfo!cboShops.AddItem (MyShop [1])
    frmJobInfo!cboShops.AddItem (MyShop [2])[/B]
    ' etc. etc. etc.
    
    
    
    
Else
    MsgBox ("You can't become a shop owner. You do not own any shops. Try saving up some cash."), , "No Shop"
End If
End Sub

As my code for when you click on cmdShopOwner. Can someone help me with why is gives me an error with the .AddItem (MyShop[1])? It highlights the [1] and says
"Compile Error:
Expected: list separator or )"

Any help will be appreciated.

Recommended Answers

All 2 Replies

frmJobInfo!cboShops.AddItem (MyShop [1] )
frmJobInfo!cboShops.AddItem (MyShop [2] )

Hi,

I think, it is the "SQUARE Bracket" troubling you.
Chanage ur code to :

.AddItem (MyShop(1) )


Regards
Veena

Aha! I have been using another language for a while (stopped using VB6), and the language uses Array[x], instead of Array(x). Thank you for your answer. It helped a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.