Error-91 VB脚本错误

时间:2018-06-29 10:26:23

标签: object

当我运行代码时提示我未设置对象变量,但总是出现错误91。 它突出显示了这一行:  当我尝试调试器时,显示“ If OptionButton3.Value Then”。我不知道问题出在哪里,我也不知道对象变量是什么?还有其他人遇到过这个问题吗?

任何帮助将不胜感激。谢谢

Sub NewEntry()

Dim cboOpName As Object
Dim TextBox1 As Object
Dim Operator As String
Dim UserForm1 As Object
Dim OptionButton1 As Object
Dim OptionButton3 As Object
Dim OptionButton11 As Object

Sheets("Sheet1").Activate

txtTitle1 = "Input Operator"
    firstline1 = "Operator" & Chr(10) & Chr(10)
    firstline = (firstline1)
        Oper = InputBox(firstline, txtTitle1)
        If Oper = "" Then
            Exit Sub
            Else
            End If
        If Oper = 0 Then
            Exit Sub
            Else
            End If

txtTitle1 = "Input Project ID Number"
    firstline3 = "Project ID No" & Chr(10) & Chr(10)
    firstline = (firstline3)
        PROno = InputBox(firstline, txtTitle1)
        If PROno = "" Then
            Exit Sub
            Else
            End If
        If PROno = 0 Then
            Exit Sub
            Else
            End If
            
txtTitle1 = "Input Date of Manufacture"
    firstline3 = "Date of Manufacture" & Chr(10) & Chr(10)
    firstline = (firstline3)
    val1 = "DD/MM/YY"
        DateM = InputBox(firstline, txtTitle1, val1)
        If DateM = "" Then
            Exit Sub
            Else
            End If
        If DateM = 0 Then
            Exit Sub
            Else
            End If
            
                     
 txtTitle1 = "Input Serial Number"
    firstline3 = "Serial Number" & Chr(10) & Chr(10)
    firstline = (firstline3)
        SerNo = InputBox(firstline, txtTitle1)
        If SerNo = "" Then
            Exit Sub
            Else
            End If
        If SerNo = 0 Then
            Exit Sub
            Else
            End If
            
 txtTitle1 = "Input Actuator ID"
    firstline3 = "Actuator ID" & Chr(10) & Chr(10)
    firstline = (firstline3)
        ActID = InputBox(firstline, txtTitle1)
        If ActID = "" Then
            Exit Sub
            Else
            End If
        If ActID = 0 Then
            Exit Sub
            Else
            End If
            
 txtTitle1 = "Input Opening Angle"
    firstline3 = "Opening Angle" & Chr(10) & Chr(10)
    firstline = (firstline3)
        Angle = InputBox(firstline, txtTitle1)
        If Angle = "" Then
            Exit Sub
            Else
            End If
        If Angle = 0 Then
            Exit Sub
            Else
            End If
            
 txtTitle1 = "Input Date of Test"
    firstline3 = "Date of Test" & Chr(10) & Chr(10)
    firstline = (firstline3)
        DateT = InputBox(firstline, txtTitle1, val1)
        val1 = "DD/MM/YY"
        If DateT = "" Then
            Exit Sub
            Else
            End If
        If DateT = 0 Then
            Exit Sub
            Else
            End If


UserForm2.Show

UserForm4.Show

Sheets("Sheet1").Activate
RowNow = 6
RowNum = 1

Do While RowNow = ""
    If RowNow <> "" Then
        RowNow = RowNow + 1
        RowNum = RowNum + 1
    Else
        Cells(RowNow, 1).Value = RowNum
        Cells(RowNow, 4).Value = PROno
        Cells(RowNow, 9).Value = DateM
        Cells(RowNow, 7).Value = SerNo
        Cells(RowNow, 8).Value = ActID
        Cells(RowNo, 2).Value = DateT
        Cells(RowNow, 3).Value = Oper
        Cells(RowNow, 10).Value = Angle
    End If
Loop

Do While Cells(RowNow, 11) = ""
    If OptionButton3.Value Then
    Cells(RowNow, 11).Value = "Yes"
    End If
    Cells(RowNow, 11).Value = "No"
    RowNow = RowNow + 1
Loop

Do While Cells(RowNow, 6) = ""
    If OptionButton11.Value Then
    Cells(RowNow, 6).Value = "Yes"
    End If
    Cells(RowNow, 6).Value = "No"
    RowNow = RowNow + 1
Loop

Do While Cells(RowNow, 5) = ""
    If OptionButton1.Value Then
    Cells(RowNow, 5).Value = "Yes"
    End If
    Cells(RowNow, 5).Value = "No"
    RowNow = RowNow + 1
Loop

End Sub


​

0 个答案:

没有答案