473,387 Members | 1,495 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,387 software developers and data experts.

VB - Select case

Hello all. I have managed to get the select case statements working using the following code:

Dim strwhichoption As String

strwhichoption = ComboBox1
ComboBox1.AddItem ("Reina")
ComboBox1.AddItem ("Sorensen")
ComboBox1.AddItem ("Cudicini")
ComboBox1.AddItem ("Van Der Sar")

Select Case strwhichoption
Case Reina
TextBox17.Text = "5"
TextBox29.Text = "31"
Case Cudicini
TextBox17.Text = "2"
TextBox29.Text = "30"
Case Sorensen
TextBox17.Text = "3"
TextBox29.Text = "31"
End Select

I want to add the name "Van der sar" to the list though (note the spaces in the name)

I tried doing the same method as above ("add item" and "case"):
Case Van Der Sar
TextBox17.Text = "3"
TextBox29.Text = "31"

But it doesn't accept it in the case because it has spaces, it says "expected end of statement" after Van. But I would like to have the full name.

Anyone know how to do this, without using the name "VanDerSar" (no spaces)

Thank you if you can help!!
Dec 5 '06 #1
2 4326
since yor case stement is selecting on a string value you need to quote the values. The correct code is

Expand|Select|Wrap|Line Numbers
  1. Select Case strwhichoption
  2. Case "Reina"
  3. TextBox17.Text = "5"
  4. TextBox29.Text = "31"
  5. Case "Cudicini"
  6. TextBox17.Text = "2"
  7. TextBox29.Text = "30"
  8. Case "Sorensen"
  9. TextBox17.Text = "3"
  10. TextBox29.Text = "31"
  11. End Select
  12.  
  13.  
Then adding Van der sar will work as it is included in quotes in the select.
Dec 5 '06 #2
since yor case stement is selecting on a string value you need to quote the values. The correct code is

Expand|Select|Wrap|Line Numbers
  1. Select Case strwhichoption
  2. Case "Reina"
  3. TextBox17.Text = "5"
  4. TextBox29.Text = "31"
  5. Case "Cudicini"
  6. TextBox17.Text = "2"
  7. TextBox29.Text = "30"
  8. Case "Sorensen"
  9. TextBox17.Text = "3"
  10. TextBox29.Text = "31"
  11. End Select
  12.  
  13.  
Then adding Van der sar will work as it is included in quotes in the select.
Ah ok. Thank you!
Dec 6 '06 #3

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

Similar topics

3
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
17
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to...
9
by: Kevin | last post by:
Hi, I am getting a syntax error Microsoft VBScript compilation error '800a03ea' Syntax error On the code below. The error references the "End Select" line Can anyone help me with what I am...
8
by: Penny | last post by:
Hi all, My browser throws this Select Case block back at me pointing out a syntax error on the line: 'Case < 251', between the word 'Case' and the '<' symbol. *************************** ...
10
by: MLH | last post by:
Suppose the following... Dim A as Date A=#7/24/2005# I wish to compare value of A against 2 other values: 1) 8/1/2005 2) 9/1/2005 Which is better and why... First:
7
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
3
by: Rob Meade | last post by:
Ok - I *think* this is only different in .net 2.0 - as I've not had any problems in the past, but then maybe I've not tried it... I have a value being read from an xml file where the value maybe...
8
by: | last post by:
Hello, This is gonna sound real daft, but how do I test a Select Case statement for variants of a theme? Here's a snippet of my code... Select Case sUsr Case "Guest", "TsInternetUser",...
1
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case...
4
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie in php and I got error in my index.php which is: 1054 - Unknown column 'p.products_id' in 'on clause' select p.products_image, pd.products_name, p.products_id,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.