VB"标签不是一种类型,不能用作表达式"

时间:2015-11-24 12:42:52

标签: vb.net

首先,我使用SO搜索并且没有找到答案。

由于我尝试使用动态标签的构建错误,程序无法编译。

以下是代码的违规部分(如何修复此错误消息)?

Label(num).text = userchoice(num) Then

错误讯息:

  

标签不是类型,不能用作表达

所有代码:

Public Class MainForm

Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim foodtype As Decimal
    Dim userchoice

    For num As Integer = 1 To 7 Step 1
        If num <= 4 Then
            foodtype = "Main course"
        ElseIf num = 5 Then
            foodtype = "Bread"
        ElseIf num = 6 Then
            foodtype = "Drink"
        ElseIf num = 7 Then
            foodtype = "Dessert"
        End If
        userchoice(num).to = InputBox(foodtype & num)
        Dim lc = userchoice(num).tolower
        Dim calories
        If lc = "stuffing" Then
            calories = 165
        ElseIf lc = "turkey" Then
            calories = 180
        ElseIf lc = "mashed potatoes" Then
            calories = 220
        ElseIf lc = "carrots" Then
            calories = 25
        ElseIf lc = "french bread" Then
            calories = 224
        ElseIf lc = "everclear" OrElse lc = "water" Then
            calories = 1
        ElseIf lc = "pudding" Then
            calories = "170"
        End If
        Label(num).text = userchoice(num) Then
    Next

End Sub
End Class

0 个答案:

没有答案