我已经浏览过互联网,但我似乎无法找到问题的答案,根据我所看到的答案,我不应该有问题。
很多代码都是草率的,因为它是以前工作的复制意大利面。意图是在功能完成后进行清理。
我将7个字符串传递给我的用户表单中的子字符,但我一直收到424错误。
来自用户形式:
Sub CommandButton1_Click()
Dim Bericht As Variant
Dim RuilingOfVermissing As String
Dim Benaming As String
Dim NSN As String
Dim Aantal As String
Dim Bijzonderheden As String
Dim DatumIn As String
Dim Naam As String
'Check verplichte velden
If OptionButton1.Value = False And OptionButton2.Value = False Then
Bericht = MsgBox("Selecteer Ruiling of Vermissing", vbOKOnly)
GoTo ErrorExit
ElseIf OptionButton1.Value = True And OptionButton2.Value = True Then
Bericht = MsgBox("Selecteer Ruiling OF Vermissing, niet allebei", vbOKOnly)
GoTo ErrorExit
ElseIf OptionButton1.Value = True Then
RuilingOfVermissing = "Ruiling"
ElseIf OptionButton2.Value = True Then
RuilingOfVermissing = "Vermissing"
End If
If Len(TextBox2 & vbNullString) = 0 Then
Bericht = MsgBox("Vul een benaming in", vbOKOnly)
GoTo ErrorExit
ElseIf Len(TextBox3 & vbNullString) = 0 Then
Bericht = MsgBox("Vul een NSN in", vbOKOnly)
GoTo ErrorExit
ElseIf Len(TextBox4 & vbNullString) = 0 Then
Bericht = MsgBox("Vul een aantal in", vbOKOnly)
GoTo ErrorExit
ElseIf Len(TextBox5 & vbNullString) = 0 Then
Bericht = MsgBox("Vul een 'datum in' in", vbOKOnly)
GoTo ErrorExit
ElseIf Len(TextBox9 & vbNullString) = 0 Then
Bericht = MsgBox("Vul je naam in", vbOKOnly)
GoTo ErrorExit
End If
'Niet verplicht veld ("bijzonderheden") aanpassen naar spatie om Null te voorkomen
If Len(TextBox7 & vbNullString) = 0 Then
TextBox7.Text = "-"
End If
Benaming = TextBox2.Text
NSN = TextBox3.Text
Aantal = TextBox4.Text
Bijzonderheden = TextBox7.Text
DatumIn = TextBox5.Text
Naam = TextBox9.Text
RuilVernis.schrijven RuilingOfVermissing, Benaming, NSN, Aantal, Bijzonderheden, DatumIn, Naam
ErrorExit:
Exit Sub
End Sub
来自被叫子:
Sub schrijven(Optional RuilingOfVermissing As String, _
Optional Benaming As String, _
Optional NSN As String, _
Optional Aantal As String, _
Optional Bijzonderheden As String, _
Optional DatumIn As String, _
Optional Naam As String)
Dim Nextrow As Variant
Sheets("Database").Select
Nextrow = Sheets("Database").Range("A65536").End(xlUp).Row + 1
Sheets("Database").Range("A" & Nextrow) = Nextrow.Text
Sheets("Database").Range("B" & Nextrow) = RuilingOfVermissing
Sheets("Database").Range("C" & Nextrow) = Benaming
Sheets("Database").Range("D" & Nextrow) = NSN
Sheets("Database").Range("E" & Nextrow) = Aantal
Sheets("Database").Range("F" & Nextrow) = Bijzonderheden
Sheets("Database").Range("G" & Nextrow) = DatumIn
Sheets("Database").Range("I" & Nextrow) = Naam
Sheets("Start").Select
Unload UserForm1
UserForm1.Show
Save
End Sub
当我运行424点时:
RuilVernis.schrijven RuilingOfVermissing, Benaming, NSN, Aantal, Bijzonderheden, DatumIn, Naam'
我做错了什么?
非常感谢提前。
答案 0 :(得分:4)
在这里,您将Nextrow
声明为一个重要的
Dim Nextrow As Variant
您为Nextrow
分配了一个数值。 Nextrow
现在实际上是一个数字。
Nextrow = Sheets("Database").Range("A65536").End(xlUp).Row + 1
由于数值没有Text
属性,因此会引发424错误。
Sheets("Database").Range("A" & Nextrow) = Nextrow.Text