我的JSON
{
"name": "username",
"status": "mystatus",
"quality": "5",
"place": {
"name": "placename",
}
目前我定义的颜色如下:
picturebox1.BackColor = Color.Magenta
我想根据质量返回的数字更改BackColor
,我不知道如何进行多重if
colors:-
0 = Gray
1 = White
2 = Green
3 = Blue
4 = Magenta
5 = Orange
6 = Beige
7 = Beige
我目前正在为文本框检索我的json字符串
placename.Text = jResults2("place")("name").ToString()
所以我认为这就像
picturebox1.BackColor = jResults2("status") Is "0", "Color.Gray,
我只是不确定如何继续
由于
答案 0 :(得分:2)
我认为使用select命令会更好。
Select Case value
Case 1
'CHANGE COLOR
Case 2
'CHANGE COLOR
Case 5
'CHANGE COLOR
Case Else
'CHANGE COLOR
End Select
因为你要求这里的代码是你的第5个......
Dim value = jResults2("place")("name").ToString()
Select Case value
Case 0
picturebox1.BackColor = Color.Gray
Case 1
picturebox1.BackColor = Color.White
Case 2
picturebox1.BackColor = Color.Green
Case 3
picturebox1.BackColor = Color.Blue
Case 4
picturebox1.BackColor = Color.Magenta
End Select