Using "AND" In Case Statements?
Mar 29, 2009Is the following case statement valid?
Case IS <=40 AND IS>=20
This was an example given by my instructor on case statement syntax but I'm getting a build error when trying to compile this.
Is the following case statement valid?
Case IS <=40 AND IS>=20
This was an example given by my instructor on case statement syntax but I'm getting a build error when trying to compile this.
i have a program, three radios, and 2 check boxes. the Radios use a constant value and do a multiplication. check one applies a discount. no problem.
the last takes the values of all three radios does a comaparison and displays a label if false, performs a subtraction if true and shows savings.problem>
very convoluted using if statements. and the output is often wrong(i know this is a logic error) i can not find the fault.
would it be easier to use case statments. can and will post code if requested. as it is in if then format currently it is rather long.
Sometimes the answer is so blindingly obvious i fail to see it.
Dim subtotal As Decimal = CDec(txtSubtotal.Text)
Dim discountPercent As Decimal
Select Case txtCustomerType.Text.ToUpper() = "R"
Case CBool(250) To CBool(500)
discountPercent = 0.25D
[code]....
i have a situation in which i have to check if the string starts with something and then perform something....First i used "If" as below
If utn.text.startswith("Fuel") then
messagebox.show("Fuel Purchase is selected")
End If
[code]....
Now i have to use Select and Case statements along with startswith...?
I am working on a calculator and I'm trying to use select case statements for the symbols selected (radio buttons) as opposed to If then Else statements. I am running into trouble because I'm only used to using them with list boxes.[code]...
View 4 RepliesIm trying to figure how to use the IF, ELSE statements OR the Select Case statement to write this program.I'm using Visual Studio 2010. The program is suppose to allow the user to input their weight in a text box and from group box 1 the select whether theyre male or female using the radios and they select inactive or active from group box two and the calculate but will determine how many calories they should intake based on the criteria below.
[Code]...
My page contains: GridView1, GridView2, Button1, Button2, DropDownList1 I bind Gridviews to the table selected in dropdown like this:
Dim results as DataTable
Select Case ddl1.SelectedValue
Case 0
[Code]....
For me it looks like a lot of overhead. How can I improve then design and only specify that I'm working on the following record in dropdown list without specifying the Case condition every time? Should I change my design or leave it like it is?
Update:
RunZero, RunOne, RunTwo, RemoveZero, RemoveOne, RemoveTwo, RemoveThree - Execute six different stored procedures.
I am trying to write a code that converts characters in string using a case select statements. For instance if I type the word "aeiou" the the word "<>[]/", also if I type "AEIOU" then <>[]/" should print but its not working here is a sample of my code so far.
[Code]...
how to associate a select case statement with, which point to four Function procedures, to four radio buttons that are used to +, -, *, and / two simple fractions in a fractions calculator. This is a class assignment for which I have already been graded. I used an If...ElseIf statment and it worked perfectly. Now I am trying to utilize the Case Statments with Function Procedures to do the same thing. I do not get graded for this, but I was told to research it an find an answer. My current code is listed below.
[Code]...
I am working on Datagridview. My task is adding buttons in the Datagridview table based on the case statements. Like In the Present table i have one column called "CategoryDescription". In this column, values are like 3101,3102, 3103........Here 31 is the common. and like 3201,3202,3203......Here 32 is the common. Like there are so many common values are there. So where ever the common values will come there i have to add one button in the Same column.
So Finally my conclsion is at Satrting 3101 and starting 3201,3301,3401.. i have to add one button control 3101 and add button control on 3201 and add button control on 3301.
can anyone give a sample code for select case statements under a button click event?
View 2 RepliesCan someone give me a site to a tutorial that will help me write a program that will generate a pattern using do while, if else statements,and do until statements. I have been using google but I can't find anything. I need to generate patterns a certain size 6 by 6 or similar such as something like a checkerboard but where the ^ symbols is there a suppose to be a blank space..
View 3 Repliesi have a program using a select case to convert letters to special charaters. My question is how can I get the code to read upper and lower case letters without having to put the upper case letters in my select case statement. Example: Part of my code is
[Code]...
i want to the textbox that when I start to type in names it should be like this Camille Aisha Cordova, How do I do this?
View 16 RepliesIm using a Random Pool number generator and was wondering how i can make it use upper-case and lower-case letters as well as numbers here is a pic
[Code]...
I want my TextBox to make the text i enter as Sentence Case(ProperCase).. but i dont want to write any code in an event like Lost Focus or KeyPress
Just by default when ever a user enter or types in a textbox the first letter of every word should automatically converted into UpperCase
When my form loads it adds some handles (using AddHandler) to a sub (showStatus). What this sub does is checks which control activated the sub (using sender.Equals) and displays text in the status label (status) accordingly.For this I use an If...Then statement for each possibility. There are many possibilities and my code get cluttered. Is there a way to do the same thing with a Select...Case statement. I tried: Select Case sender Case tbOne : status.Text = "blahblahblahblahblahblah" End Selectwhere: tbOne is a textbox, status is a StatusLabelIt gives me an error though, saying "Operator '=' is not defined for types 'Object' and 'System.Windows.Forms.TextBox'."Any ideas on how I can get this to work with a select case statement?
View 13 Replieshere is my code..
[Code]....
If the result is 86 and it's mod by 43 the answer is 2 Case 2 is not firing. it just goes to the end of the procedure.
I am trying to figure out how to do this:
if (phrase = hello) then
"say hello"
if (phrase = how are you?) then
[CODE]...
So basically, I want it to work like a timeline. If I say hello, then it will respond and move onto the next if statement. Get it?
Here is the code I have now:
If phrase.Result.Text = "hello" Then
synth.Speak("Hello to you too")
If phrase.Result.Text.Contains("How are you") Then
[CODE]...
It looks like impossible but...
Try
Select Case command
Case 1
smth()
Case 2
[code]....
Firstly Case 2 runs. Throws exception. And right after this debugger shows that next processed statement is Case Else. Only after Case Else throws own exception Catch block start working. I've never seen this trick. Why can this happened?I'm sure the block is entered once (not like this:first enter hit Case 2 and second hit Case Else).
Update:-To Matt Wilko. Thank you for answering. I've switch to Strict On in Options of VS2010 but nothing has changed. Command is variable, not function. Watch tool shows that on each step Command is the same ( Command = 2).
Fixed. Yeeaaaahhh. I simplefy code to
Try
Select Case 2
Case 2
[code]....
and change project to Console app. This works as I mention. The fix was in Release mode. I was debugging in Release mode. When I switch to Debug mode everything goes as it should.
I need to add Functions for the Case 10 and Case 13 in this code. The code in each select case needs to be moved to the two functions which then returns the code once its called from the Sub Main section. But I am having a really hard time figuring out what exactly gets moved to each function.[code]I'm not sure what exactly to put into the individual Functions and how to change up the Sub Main section.
View 4 RepliesI have coded a case statement that changes the background colour of a panel. [code]When the code is run, it works for the case of colour1 that is NOT 1 or 2. However, when the colour1 is 1 or 2, it is supposed to pick a number from set array and run another case statement. Instead, it only picks the last value (for 1, this is 5, and for 2, this is 7).
View 3 RepliesI have to Create a Bowling Scores application that allows the user to enter 5 scores and then displays the high score and the low score and then clicking on the Statistics button there would be a label showing which is higher and lower. We HAVE TO USE FOR AND NEXT STATEMENTS.
View 7 RepliesHow can i implement a statement with if for this number to be greater than 0 but less than 10? More Specifically where would the < 10 go?
Quote:
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
[code].....
is there any way to use 2 for every.... statements?
i want to load up my.settings and 1 list will make new toolstripdropdownitem and the other lists is for the tooltiptexts
or I could do it another way, but how can I check the index of items in a my.setting string collection? like if I want to get the text of index number 3 how do I do that?
I am using Microsoft Visual Studio 2008 with VB.NET, and in class we were assigned this project: A procedure should calculate a 2% price increase on all red shirts, but a 1% price increase on all other items. In addition to calculating the price increase, the procedure also should calculate the new price. You can use the variables strItemColr, strItem, decOrigPrice, decIncrease, and decNewPrice. Format the original price, price increase, and new price in the lblOriginal, lblIncrease, and lblNewPrice controls, respectively.
View 1 RepliesBasically if i wanted my controls to be checked at startup id use a setting obviously
'UI Settings
chkCloseToTray.Checked = My.Settings.CloseToTray
chkAlwaysShowSystemTrayIcon.Checked = My.Settings.AlwaysShowTrayIcon
[code].....
how to combine this 2 statment..
IsConnected("Select * from manager_table", False)
Call Loader()
IsConnected("Select * from Clerk_table", False)
Call Loader()
i hve 2 listview, 2 table from accessdatabase..i put listview in tabcontrol..1 in tab 1 & second in tab 2...
I need to know if this particular block of code will work, and if not, what i need to do to make it work. I'm doing touchy business and i'd prefer to have it right the first time.
strsql = "IF COL_LENGTH('orders','nosign') IS NULL" & _
"BEGIN" & _
"ALTER TABLE orders" >& _
"ADD nosign bit;" & _
"END"
How do I make an OR Statement.
Im trying to do this
name3 = [name2].EndsWith("," Or "." Or "?" Or "!" Or ";" Or ":")