0

我有这个form

在此处输入图像描述

我有这个code

'For Tab Schedule
Dim Schedule_Tab = frmSettings.Tab_Schedule.Controls 'the tab page for schedule
Dim Panel_Set_Num As String
Dim Set_Num As String = "00"

Public Function Schedule_Get() As String
    For Each Ctrl_Panel_Set As Control In Schedule_Tab
        If TypeOf Ctrl_Panel_Set Is Panel And Ctrl_Panel_Set.Name.StartsWith("Panel_Set_") Then
            For Each Ctrl_Lbl_Temp In Ctrl_Panel_Set.Controls
                If TypeOf Ctrl_Lbl_Temp Is Label Then
                    If Ctrl_Lbl_Temp.Name.StartsWith("Lbl_Temp_") Then
                        If Ctrl_Lbl_Temp.Text = "0" Then
                            Panel_Set_Num = CType(Ctrl_Panel_Set, Panel).Name
                            Set_Num = "CSR" & Panel_Set_Num.Substring(Panel_Set_Num.Length - 2) & "^"
                            Return Set_Num
                        End If
                    End If
                End If
            Next
        End If
    Next Ctrl_Panel_Set
    Return "Done"
End Function

我有这个error

1.没有“As”子句的变量声明;假定的对象类型。

2.警告视为错误:没有“As”子句的变量声明;假定的对象类型。

错误出现在这emphasize行代码中。

Dim Schedule_Tab = frmSettings.Tab_Schedule.Controls 'the tab page for schedule

我试图按照错误所说的那样去做,但它导致了这种错误。changed Dim Schedule_TabDim Schedule_Tab As Form.ControlCollectionAn unhandled exception of type System.TypeInitializationException' occurred in xxxxxxxxx.exe

Questions:

  1. 在那种情况下我该怎么办?
  2. 我应该如何申报Schedule_Tab
4

2 回答 2

1

应该这样声明:

Dim Schedule_Tab As Control.ControlCollection = frmSettings.Tab_Schedule.Controls
于 2015-08-10T02:42:43.053 回答
0

尝试

Dim Schedule_Tab as New frmSettings.Tab_Schedule.Controls
于 2015-08-10T01:10:41.483 回答