473,793 Members | 2,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB - Select case

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

Dim strwhichoption As String

strwhichoption = ComboBox1
ComboBox1.AddIt em ("Reina")
ComboBox1.AddIt em ("Sorensen")
ComboBox1.AddIt em ("Cudicini")
ComboBox1.AddIt em ("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 4349
Andrew Thackray
76 New Member
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
gozzer101
8 New Member
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
5198
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 using check boxes. For example, a question such as
17
14648
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 allow entry to one or the other or Both at the same time. Now I tried to use an If ElseIf but it got too hard to track, so now I am using a SELECT CASE Statement.
9
3633
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 doing wrong? Thanks
8
3774
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. *************************** intWeightTotal = 550 Select Case intWeightTotal
10
2170
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
9340
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
3778
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 a word or a number, ie... Low or 1 Medium or 2 High or 3
8
4723
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", "krbtgt", "quality7" ' don't show
1
21690
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 "01" : dWarrExpDateMonth="Jan" : dRetailDateMonth="Jan" case "02" : dWarrExpDateMonth="Feb" : dRetailDateMonth="Feb" End Select
4
10682
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, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd,...
0
9518
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10433
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10212
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10161
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.