2 just oracle just_oracle 于 2014.12.04 10:09 提问

VBA中提示子程序或函数未定义?

Private Sub CommandButton1_Click()
Dim DoubleTemp As Double
Dim ll_Pos As Long
Dim PanelName() As String
Dim DexStr As String
Dim StringTemp As String
Dim Extract As New TBDex
Dim Extract_1 As New TBDex

Dim Val As Variant


DexStr = "hull.block(*).panel(*).name"
Extract.DoDataExtraction DexStr
I = 1
Val = Extract.GetValue

ReDim PanelName(1)
While TypeName(Val) = "String"
   PanelName(I) = Val
   I = I + 1
   Val = Extract.GetValue
   ReDim Preserve PanelName(UBound(PanelName) + 1)
Wend
    If I < 2 Then
    res = WarningMsg("PanelName not found!")
    Exit Sub
End If

DeleteWorkSheet ("板材加工信息")
Set NewSheet = Worksheets.Add
NewSheet.Name = "板材加工信息"
Worksheets("板材加工信息").Activate

NewSheet.Cells(1, 1) = "零件编号"
NewSheet.Cells(1, 2) = "单元批次"
NewSheet.Cells(1, 3) = "切割图号"
NewSheet.Cells(1, 4) = "单件重量"
NewSheet.Cells(1, 5) = "零件数量"
NewSheet.Cells(1, 6) = "零件面积"
NewSheet.Cells(1, 7) = "零件厚度"
NewSheet.Cells(1, 8) = "零件宽度"
NewSheet.Cells(1, 9) = "零件长度"

NewSheet.Columns("A:A").Select
Selection.ColumnWidth = 8.88
NewSheet.Columns("B:B").Select
Selection.ColumnWidth = 8.88
NewSheet.Columns("C:C").Select
Selection.ColumnWidth = 8.38
NewSheet.Columns("D:D").Select
Selection.ColumnWidth = 8.38
NewSheet.Columns("E:E").Select
Selection.ColumnWidth = 8.38
NewSheet.Columns("F:F").Select
Selection.ColumnWidth = 8.88
NewSheet.Columns("G:G").Select
Selection.ColumnWidth = 8.38
NewSheet.Columns("H:H").Select
Selection.ColumnWidth = 8.38
NewSheet.Columns("I:I").Select
Selection.ColumnWidth = 10.38

nrow = 1
For K = 1 To I - 1
    nrow = nrow + 1
    ll_Pos = InStr(PanelName(K), "-") '-在字符中第几个出现
    If ll_Pos > 0 Then
        NewSheet.Cells(nrow, 1) = Mid(PanelName(K), ll_Pos + 1) '从左边ll_Pos+1个字符开始取剩余全部
        NewSheet.Cells(nrow, 2) = Mid(PanelName(K), 1, ll_Pos - 1) '从左边第一个字符开始取ll_Pos-1个字符
    End If

    DexStr = "HULL.PANEL(" + Chr$(39) + PanelName(K) + Chr$(39) + ").WEIGHT"
    NewSheet.Cells(nrow, 4) = DexStr
    Extract.DoDataExtraction DexStr
    Val = Extract.GetValue
    DoubleTemp = 0
    If TypeName(Val) = "Double" Then
       DoubleTemp = Val
    End If
    NewSheet.Cells(nrow, 4) = DoubleTemp

    DexStr = "HULL.PANEL(" + Chr$(39) + PLATE(K) + Chr$(39) + ").AREA"
    Extract.DoDataExtraction DexStr
    Val = Extract.GetValue
    DoubleTemp = 0
    If TypeName(Val) = "Double" Then
       DoubleTemp = Val
    End If
    NewSheet.Cells(nrow, 6) = DoubleTemp

    DexStr = "HULL.PANEL(" + Chr$(39) + PLATE(K) + Chr$(39) + ").THICKNESS"
    Extract.DoDataExtraction DexStr
    Val = Extract.GetValue
    StringTemp = ""
    If TypeName(Val) = "String" Then
       StringTemp = Val
    End If
Next K
UserForm3.Hide

End Sub


2个回答

iamlaosong
iamlaosong   2014.12.04 10:56

出错后光标会指向错误处的函数或过程,看那个函数或过程是否存在?有没有写错?

Topc008
Topc008   Rxr 2014.12.04 17:32

隔几行(或认为可能有错误的地方)设一个断点,看看到底是哪个函数或子过程未定义.....

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!