SRL Archive - General

VB Help


sm321

2012-02-06 07:45:54

I'm on visual basic now, and I want a label to say: If number = 1-15 = "Poor", 16-35 = "Average" 35+ "Excellent". How would I do it shorter than
if labelx = "1" then labelx ="poor"
end if
if labelx = "2" then labelx = "poor"
end if etc.

Brandon

2012-02-06 07:56:40

From: sm321
I'm on visual basic now, and I want a label to say: If number = 1-15 = "Poor", 16-35 = "Average" 35+ "Excellent". How would I do it shorter than
if labelx = "1" then labelx ="poor"
end if
if labelx = "2" then labelx = "poor"
end if etc.


Switch case statement

Switch(X)
Case 1:
LabelX.Text = "";
Break;
Case 2:
.....
Break;

Default:
......
Break;

Ps I'm missing brackets.. U can fill them in of course

sm321

2012-02-06 08:02:45

From: ggzz
Switch case statement

Switch(X)
Case 1:
LabelX.Text = "";
Break;
Case 2:
.....
Break;

Default:
......
Break;

Ps I'm missing brackets.. U can fill them in of course


So Label4.Text = If Label1.Text = ?

Brandon

2012-02-06 08:20:41

From: sm321
So Label4.Text = If Label1.Text = ?



Edit this to suit your needs


[FONT=Arial][COLOR=Black][COLOR=Blue]Dim[/COLOR] number [COLOR=Blue]As[/COLOR] [COLOR=Blue]Integer[/COLOR] = 8
[COLOR=Blue]Select[/COLOR] [COLOR=Blue]Case[/COLOR] number [COLOR=Blue]
Case[/COLOR] 1 [COLOR=Blue]To[/COLOR] 10
LabelX.Text = "10%"
[COLOR=Blue]Case[/COLOR] 1000 To 5000
LabelX.Text = "1000%"

[COLOR=Blue]Case[/COLOR] 1000000 To 10434242
LabelX.Text = "fsdfsgsdgsdgsdgs"

[COLOR=Blue]Case[/COLOR] [COLOR=Blue]Else[/COLOR]
LabelX.Text = "Bad percentage(%)"
[COLOR=Blue]End[/COLOR] [COLOR=Blue]Select[/COLOR][/COLOR][/FONT]

sm321

2012-02-06 08:29:36

From: ggzz
Edit this to suit your needs


[FONT=Arial][COLOR=Black][COLOR=Blue]Dim[/COLOR] number [COLOR=Blue]As[/COLOR] [COLOR=Blue]Integer[/COLOR] = 8
[COLOR=Blue]Select[/COLOR] [COLOR=Blue]Case[/COLOR] number [COLOR=Blue]
Case[/COLOR] 1 [COLOR=Blue]To[/COLOR] 10
LabelX.Text = "10%"
[COLOR=Blue]Case[/COLOR] 1000 To 5000
LabelX.Text = "1000%"

[COLOR=Blue]Case[/COLOR] 1000000 To 10434242
LabelX.Text = "fsdfsgsdgsdgsdgs"

[COLOR=Blue]Case[/COLOR] [COLOR=Blue]Else[/COLOR]
LabelX.Text = "Bad percentage(%)"
[COLOR=Blue]End[/COLOR] [COLOR=Blue]Select[/COLOR][/COLOR][/FONT]


Thanks, fixed :)