473,324 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

End of Statement Expected

Hey guys, I'm in high school, and just for a little personal project, I was trying to write a program, and I've got it pretty much downpat, but after the line "Dim lstPizza(8).Items" within this sub:
"Private Sub fmPizza_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim lstPizza(8).Items
End Sub" it comes up with "End of Statement Expected". I have chatted to my teacher, but he is unsure what to do about it. What should I do???
Apr 23 '10 #1

✓ answered by MrMancunian

@ggeu
Who is talking about vb6? OP didn't mention anything about that and also he posted in the .NET-forum...

@Aussie1333: When you declare something, you want to give it a type. Generally, it looks like this:
Expand|Select|Wrap|Line Numbers
  1. Dim variablename As Type
I guess you have in mind that you want to display a list of pizza's in a listbox. For that, you want to create an array of 8 items. Of course, these are all hypothetical assumptions. Say you want to save 8 different names of pizza's. A name is a string, so you create a string array.
Expand|Select|Wrap|Line Numbers
  1. Dim strPizzaArray(7) as String
Check out the MSDN on Arrays to learn more. Now, you have an array of 8 empty strings (0...7) you want to fill. You can do that like this:
Expand|Select|Wrap|Line Numbers
  1. strPizzaArray(0) = "Pepperoni"
  2. strPizzaArray(1) = "Funghi"
  3. strPizzaArray(2) = "Quattro Formaggio"
  4. etc...
Now, I'm assuming you have a Listbox on a form called Listbox1. You can loop through the array with pizza names to add them to the lisbox. It should look a bit like this:
Expand|Select|Wrap|Line Numbers
  1. For a As Integer = 0 to strPizzaArray().Length - 1
  2.   Listbox1.Items.Add(strPizzaArray(a))
  3. Next
I think this should answer some of your questions. Have fun!

Steven

7 2762
Guido Geurs
767 Expert 512MB
@Aussie1333
dear,

Is this vb6 or vb.net ????

br,
Apr 23 '10 #2
semomaniz
210 Expert 100+
Dim lstPizza(8).Items is this even valid ? What are you trying to declare?

Read Below

http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx

http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx
Apr 23 '10 #3
Guido Geurs
767 Expert 512MB
dear,

I have never seen a Dim in vb6 with points !!!
If you want to dim a array then (like in your URL) =>

Expand|Select|Wrap|Line Numbers
  1. Public Sub LongTask(ByVal Duration As Single, _
  2.                      ByVal MinimumInterval As Single)
  3.    Dim Threshold As Single
  4.    Dim Start As Single
  5.    Dim blnCancel As Boolean
An array is =>

Expand|Select|Wrap|Line Numbers
  1. Dim MyArray(8) as integer
When you dimension a var then VB6 gives a list of the possibilities (see attached as...JPG.
And a red colored line if the syntax is wrong (see attached JPG)

br,
Attached Images
File Type: jpg as....JPG (18.2 KB, 547 views)
File Type: jpg dim error.JPG (7.8 KB, 277 views)
Apr 23 '10 #4
MrMancunian
569 Expert 512MB
@ggeu
Who is talking about vb6? OP didn't mention anything about that and also he posted in the .NET-forum...

@Aussie1333: When you declare something, you want to give it a type. Generally, it looks like this:
Expand|Select|Wrap|Line Numbers
  1. Dim variablename As Type
I guess you have in mind that you want to display a list of pizza's in a listbox. For that, you want to create an array of 8 items. Of course, these are all hypothetical assumptions. Say you want to save 8 different names of pizza's. A name is a string, so you create a string array.
Expand|Select|Wrap|Line Numbers
  1. Dim strPizzaArray(7) as String
Check out the MSDN on Arrays to learn more. Now, you have an array of 8 empty strings (0...7) you want to fill. You can do that like this:
Expand|Select|Wrap|Line Numbers
  1. strPizzaArray(0) = "Pepperoni"
  2. strPizzaArray(1) = "Funghi"
  3. strPizzaArray(2) = "Quattro Formaggio"
  4. etc...
Now, I'm assuming you have a Listbox on a form called Listbox1. You can loop through the array with pizza names to add them to the lisbox. It should look a bit like this:
Expand|Select|Wrap|Line Numbers
  1. For a As Integer = 0 to strPizzaArray().Length - 1
  2.   Listbox1.Items.Add(strPizzaArray(a))
  3. Next
I think this should answer some of your questions. Have fun!

Steven
Apr 23 '10 #5
@MrMancunian
I already had the listbox and I had checkboxes and radio buttons to add their text to the listbox, so how do I make it possible for those to be copied?
Apr 27 '10 #6
MrMancunian
569 Expert 512MB
Please rephrase your question...

"How do I make it possible for <WHAT?> to be copied <WHERE>?"

Steven
Apr 27 '10 #7
ok. How do I make it possible for the contents of my listbox to be copied to a word processor or to the clipboard?
May 4 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Phil Powell | last post by:
Here is the function ArraySearch: '-------------------------------------------------------------------------------------- 'ArraySearch will return an integer value indicating the first...
7
by: Graham James Campbell CS2000 | last post by:
Having a nightmare problem with this and would appreciate any and all help. The situation is I want to move from a webform and format the user inputted text into some html I am storing in a...
6
by: Oli | last post by:
Hi, Im trying to use a sesson statement within an SQL Statement: sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company") & "" And get the error: Error Type:
3
by: Matt | last post by:
When the ASP statement end with a _ character, then the next line cannot have comment ' character. Is that correct? Since I encountered the following error: Microsoft VBScript compilation...
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
2
by: Edward S | last post by:
I would appreciate if someone could correct my SQL statement which is displaying a message Expected : End of Statement this statment is attached to a button on the form StrSQL = "PARAMETERS !!...
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
1
by: Jean-Marc Blaise | last post by:
Hi folks, In case the SQL statement is not written properly, we sometimes get strange messages. The 2 following statements are simple inversion between order by and group by clause. We get an...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
1
by: nosaj070 | last post by:
Hi, I'm working on a project and it is my first time implementing VBA with Access. I know my SQL Statement is close, but it obviously isn't perfect, if any of you can see what the error is I'd really...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.