0

这是我为我的项目制作的 VB.Net 2012 程序。我希望你能帮助我。

我已经在库存按钮代码中尝试过此代码,但它不起作用。

Dim rad1 As String = 0
Dim rad2 As String = 0
Dim rad3 As String = 0
Dim rad4 As String = 0
Dim rad5 As String = 0
Dim rad6 As String = 0
Dim rad7 As String = 0
Dim rad8 As String = 0

Dim siomairice As String
Dim friedsiomai As String
Dim siomai As String
Dim threesiomai As String
Dim coke As String
Dim sprite As String
Dim rc As String
Dim sevenup As String

If rad1 = radS2.Checked Then
    siomairice = rad1
    siomairice = siomairice + 1
    siomairice = Form5.Label1.Text
End If
If rad2 = radS2.Checked Then
    friedsiomai = rad2
    friedsiomai = friedsiomai + 1
    friedsiomai = Form5.Label2.Text
End If
If rad3 = radS3.Checked Then
    siomai = rad3
    siomai = siomai + 1
    siomai = Form5.Label3.Text
End If
If rad4 = radS4.Checked Then
    threesiomai = rad3
    threesiomai = threesiomai + 1
    threesiomai = Form5.Label4.Text
End If
If rad5 = radD1.Checked Then
    coke = rad5
    coke = coke + 1
    coke = Form5.Label5.Text
End If
If rad6 = radD2.Checked Then
    sprite = rad6
    sprite = sprite + 1
    sprite = Form5.Label6.Text
End If
If rad7 = radD3.Checked Then
    rc = rad7
    rc = rc + 1
    rc = Form5.Label7.Text
End If
If rad8 = radD4.Checked Then
    sevenup = rad8
    sevenup = sevenup + 1
    sevenup = Form5.Label8.Text
End If

它在程序本身中没有任何错误或警告,但是当我单击它时它没有任何响应。

4

1 回答 1

0

这段代码永远不会起作用。例如If rad1 = radS2.Checked Then--rad1是一个值为“0”的字符串。我假设radS2.Checked是单选按钮属性,即boolean. 您比较字符串值“0”和布尔值,它是TrueFalse在其字符串等效项中。所以,里面的代码If永远不会执行

例如第二个问题

siomai = Form5.Label3.Text

如果要在标签上显示文本,则需要

Form5.Label3.Text = siomai 

第三个问题 - 整个逻辑很疯狂。应该是这样的:

private _rad1Clicks as Integer

private sub rad1_Click (sender as object, e as eventArgs) Handles rad1.Click
    _rad1Clicks += 1
    myForm.myLabel.Text = _rad1Clicks.ToString()
End sub
于 2013-10-07T15:14:08.827 回答