查询代码中的一些错误检测

时间:2014-01-09 08:56:40

标签: vb.net

    Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
        Dim tempport As Object
        Dim tempip As Object
        Dim tempid As Object
        Dim i As Integer
        serverid = m1.GetINISetting("STARTUP", "SERVERID" & i, My.Application.Info.DirectoryPath & "/svrinfo.ini")
        serverport = m1.GetINISetting("STARTUP", "PORT" & i, My.Application.Info.DirectoryPath & "/svrinfo.ini")
        serverip = m1.GetINISetting("STARTUP", "IP" & i, My.Application.Info.DirectoryPath & "/svrinfo.ini")
        agentid = m1.GetINISetting("STARTUP", "AGENTID" & i, My.Application.Info.DirectoryPath & "/svrinfo.ini")
        lblserverid.Text = serverid
        lblagentid.Text = agentid
        lblzoneport.Text = serverport
        lsip = m1.GetINISetting("LOGINSERVER", "IP", My.Application.Info.DirectoryPath & "/svrinfo.ini")
        lsport = CShort(m1.GetINISetting("LOGINSERVER", "PORT", My.Application.Info.DirectoryPath & "/svrinfo.ini"))
        zonecount = CShort(m1.GetINISetting("ZONESERVER", "COUNT", My.Application.Info.DirectoryPath & "/svrinfo.ini"))
        Dim zonelist(zonecount, 3)
        For i = 0 To zonecount - 1
            tempid = m1.GetINISetting("ZONESERVER", "ID" & i, My.Application.Info.DirectoryPath & "/svrinfo.ini")
            tempip = m1.GetINISetting("ZONESERVER", "IP" & i, My.Application.Info.DirectoryPath & "/svrinfo.ini")
            tempport = m1.GetINISetting("ZONESERVER", "PORT" & i, My.Application.Info.DirectoryPath & "/svrinfo.ini")
            If Not tempid = 0 Then sock_zone.Load(tempid)
            sock_zone(tempid).Protocol = MSWinsockLib.ProtocolConstants.sckTCPProtocol
            sock_zone(tempid).RemoteHost = tempip
            sock_zone(tempid).RemotePort = tempport
            sock_zone(tempid).Connect()
            zonelist(i, 0) = tempid
            zonelist(i, 1) = tempip
            zonelist(i, 2) = tempport
            combozoneiostatus.Items.Add((tempip & ":" & tempport & ":" & tempid))
            System.Windows.Forms.Application.DoEvents()
        Next i
        combozoneiostatus.SelectedIndex = 0
        sock_LS.Protocol = MSWinsockLib.ProtocolConstants.sckTCPProtocol
        sock_LS.RemoteHost = lsip
        sock_LS.RemotePort = lsport
        sock_LS.Connect()
        System.Windows.Forms.Application.DoEvents()
        Call refreshzonestatus()
        ReDim clientpreparedinfo(1, 4)
        ReDim clientinfo(1, 5)
        sock_client(0).Protocol = MSWinsockLib.ProtocolConstants.sckTCPProtocol
        sock_client(0).LocalPort = serverport
        sock_client.Load(1)
    End Sub

clientpreparedinfo& clientinfo'ReDim'无法更改数组的维数。 当我添加Dim时,它给出了没有'As'子句的变量声明;假定的对象类型。

1 个答案:

答案 0 :(得分:1)

Variable declaration without an 'As' clause; type of Object assumed表示您遗漏As SomeType。所以它是Dim clientpreparedinfo(1,4) As SomeTypeDim clientinfo(1, 5) As SomeType(用String,Integer或其他类型替换SomeType)。