Use The IF ELSE Statements OR The Select Case Statement To Write?
Oct 7, 2011
Im 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]...
View 14 Replies
ADVERTISEMENT
Feb 20, 2009
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]....
View 6 Replies
Jul 10, 2009
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...?
View 4 Replies
Sep 19, 2010
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 Replies
Oct 19, 2009
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]...
View 11 Replies
May 26, 2010
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]...
View 8 Replies
Mar 21, 2006
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 Replies
May 5, 2010
can anyone give a sample code for select case statements under a button click event?
View 2 Replies
Jun 23, 2010
A co-worker wants to convert the following IfThenElseIf statement into a Select Case statement.
Explain why this is not possible.
If temperature = 100 Then
X = 0
ElseIf population > 1000 Then
X = 1
ElseIf rate < .1 Then
X = -1
End If
View 7 Replies
Oct 28, 2009
i 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]...
View 6 Replies
Jun 3, 2011
I just replaced a different segment of code with the select case statement and it works fine. However I don't understand what the dim is for after you do "Select case [variable name here]"
I currently just dimmed a value as nothing. I didn't specify any data type for my variable I'm using for this case statement. But it works.[code]...
View 4 Replies
Dec 17, 2011
I've got the following that has got multiple values of a particular variable and I don't want to stack up to a lot of IF ELSE statements to handle them, so I'd be grateful if some one could very kindly modify the code by using the SELECT CASE statement. Also, I'd like dgMarksEntry.Item(7, i).Value and dgMarksEntry.Item(8, i).Value to handle RANK and COUNT the number of items entered respectively. [Code]
View 2 Replies
Sep 22, 2010
Is there a way to use the Select Case statment in VB.net for beginswith? Or do i have to use a long elseif? Example:
If text.StartsWith("/go") then
elseif test.StartsWith("/stop")
elseif test.StartsWith("/continue")
[Code]....
View 3 Replies
Jul 13, 2011
I am trying to type in the food Pizza, Taco or Crepe and get a picture of the food to come up along with a message box that gives the country.[code]
View 3 Replies
Oct 20, 2009
I am not really a fan of if statements. I think they should only be used when comparing different values like this:
Dim status as boolean = false
Dim number as integer = 5
if status.equals(true) then
[Code]....
or msgbox on a different line whatever you want.... What is this rule about that select case should only be used if there more then 2-3 options. Is it wrong to use a select case instead?
View 23 Replies
Sep 1, 2010
in combo box string is xxx and yyy and zzz.we have to store the value to each string like xxx=10, yyy=20 and zzz=30. formula is string(xxx)/1.71^(1/2).. if we select xxx formula have to take value 10 or yyy means formula have to take value 20.
View 2 Replies
Apr 15, 2010
Is there anyway I can build a Select statement that uses the Contains function? Like this:
Select commentStr
Case commentStr.Contains("10")
Case commentStr.Contains("15")
View 1 Replies
Mar 10, 2009
am using VB.NET 2008 and am a complete beginner. am writing a programme that requires the user to select a number from a NumericUpDown control and the number selected will enable the equivalent number of GroupBoxes on a form following a click event.
[Code]...
think that the argument to be passed to the method or sub will be the Case condition but how do I return the corresponding code to enable the GroupBoxes? I have the same issue with resetting all my textboxes to some default text then the user activates more then one event.
View 6 Replies
Nov 21, 2009
I am a noob and I am trying to make a simple resistance calculator for practice. I use text boxes to let the user input the current and voltage, and then a combo box for the units and then a list box to display the results. For some reason no matter which units I select it doesn't convert at all. For example 1/2 will always show up as 0.5 in the list box no matter which units are selected from the combo box. Here is my code.....I know that there is more cases but I only put one to see if it
Public Class Form1
Dim unitsA As String
Dim unitsV As String
[code].....
View 1 Replies
Mar 23, 2009
My code is:
CODE:
Now i want to know can i use select case instead of if (condition)statement in this code?
View 4 Replies
Oct 17, 2009
I have trouble of writing the select case statement. I am trying to select the first case to change the labels text and if I select the case again then show up the messagebox.
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Select Case test
Case test
Label1.Text = "test"
[code]....
When I selected the button which the labels text have changed and I have selected the button again, but the messagebox doesn't appear on the screen.
View 3 Replies
Dec 10, 2007
what is the propert way to use Case statement for;When user click on a button it will show different picture everytime.I do not want a random generator. Just show pictures in order
View 10 Replies
Sep 6, 2011
This error occurs occasionally in Production but I can't reproduce it in DEV
System.NullReferenceException: Object reference not set to an instance of an object.
at CommandCenterHeader.ascx.vb:line 23
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
[Code]...
View 3 Replies
Jul 4, 2011
I want to check the current time with the half an hour time slots (total of 48 starts from 00:00,00:30,01:00,....23:30). Is it possible using select case statement.
I am storing the current time in an object.
Dim datime As DateTime = DateTime.Now.ToString("t")
now i need to do conditional check on this variable. under whichever the time slot the variable belongs, i need to write a value under corresponding timeslot.
View 2 Replies
Aug 19, 2009
I'm working through a programming project, which should be quite easy but im stuck right at the start (relatively new to VB). I have a textbox (named textbox1) and a checkbox next to it. I want the checkbox to be ticked (.checked) when ever the value in the textbox is between 1 and 100, the checkbox to not be ticked when theres nothing in there, and for it not to be ticked when the value is < 1 and > 100. Figured a case statement would be the easiest. (this piece of code is just a validation check, basically in the real thing the user would have to enter in a value between 1 and a given number, and need to tell the user if that value is valid).
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Select Case TextBox1.Text
Case Is = ""
[code]....
But what happens is, if I enter in the value 1 in the textbox, the checkbox becomes ticked, as it should. It tick with any values between 2 and 99 (any number not starting with 1) but the checkbox becomes ticked again when the value is 100. For any other range, say 1 to 70, the checkbox would be ticked if the value in the textbox is 1 to 7, or any number starting with 1 or 7, but not 8 or 9, or any number starting with 8 or 9.
View 3 Replies
Jan 10, 2012
Is there a way to pass data from a Select Case statement to an array? i.e. I have a gradebook program I'm working on which specifies that I'm to create a form with a menu that will open another form which has textboxes for 5 student names and 5 grades for each. I need to use an array that holds 5 student names (done), an array of 5 strings to hold each students' letter grade (?) and 5 arrays of 5 numbers to hold each student's set of test scores (done). What I can't figure out is how to get th
Public Class StudentData
Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
[code]......
View 8 Replies
Oct 13, 2009
i have a table with information on how much tax a company has to pay, and i need to put it into a select case statement that will let me display the results, but i have no idea how to do that.
this is the table:
Sales Income OverBut Not OverCompany Tax IsOf the Amount Over
$0 $50,000 1% $0
$50,000 $150,000 $500 + 2% $50,000
$150,000 $300,000 $3,000 + 3% $150,000
$300,000 $500,000 $9,000 + 4% $300,000
$500,000 - $20,000 + 5% $500,000
how do i display this? i have no clue where to start..
View 5 Replies
Nov 18, 2009
While measuring the select case performance I encounter a strange behavior of Select Case statement with the constant expression. I don't understand why its behavior is dependent on the values to be compared.
[Code]...
View 3 Replies
Jan 14, 2009
I have problem with select case statement. When I click the button, nothing have happens.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim google As String
Select Case google
Case 0
[code]....
View 39 Replies
Oct 18, 2011
Say I have this in VB.NET:
Dim executeB As Boolean
Select Case myVariable
Case "a"
'some code
Case "b"
'some code
Case Else
End Select
If myVariable is "a", control will go into the first case statement. Now let's say if myVariable = "a", but inside a's case block, I find that executeB is true, is it then possible to jump to the second case?
View 5 Replies