|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Select Case confusion
Sorry I should have been more descriptive. The problem I am having is with the TotalValue variable, am I not assigning things right here or
is there something wrong with my Select Case decision making? I have the same problem using IF...Then statements. Try this code and if you would and please help me understand why the TotalValue variable is not storing the string I assign to it please. PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim FirstValue AsInteger Dim SecondValue AsInteger Dim TotalValue AsInteger Dim ValueToDisplay AsString FirstValue = txtFirstValue.Text SecondValue = txtSecondValue.Text ValueToDisplay = lblMessage.Text TotalValue = FirstValue * SecondValue lblTotalValue.Text = TotalValue SelectCase TotalValue Case TotalValue > 100 ValueToDisplay = "This is a Big Number" Case TotalValue < 100 ValueToDisplay = "This is a Little Number" EndSelect MessageBox.Show("Reached the end of the program") EndSub Last edited by lsrouse : March 30th, 2004 at 11:42 AM. Reason: Code Looks Terrible |
|
#2
|
|||
|
|||
|
Yes I'm just as confused!
Ok so was the question not clear enough?
|
|
#3
|
||||
|
||||
|
try this (assuming it is VB.NET and not Visual Basic)
Code:
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FirstValue As Integer
Dim SecondValue As Integer
Dim TotalValue As Integer
Dim ValueToDisplay As String
FirstValue = Integer.Parse(txtFirstValue.Text)
SecondValue = Integer.Parse(txtSecondValue.Text)
TotalValue = FirstValue * SecondValue
lblTotalValue.Text = TotalValue
Select Case TotalValue
Case TotalValue > 100
ValueToDisplay = "This is a Big Number"
Case TotalValue < 100
ValueToDisplay = "This is a Little Number"
End Select
lblMessage.Text = ValueToDisplay
MessageBox.Show("Reached the end of the program")
End Sub
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Select Case confusion |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|