你能帮我搜索和打印由文本指定的文件textbox1
吗?我有以下代码,但textbox1
显示了一个错误。我不知道代码是否正确编写并且运行正常。
第一课:
Public Class tisk
'print
Public Shared Function printers()
Dim printThis
Dim strDir As String
Dim strFile As String
Dim Textbox1 As String
strDir = "C:\_Montix a.s. - cloud\iMontix\Testy"
strFile = "C:\_Montix a.s. - cloud\iMontix\Testy\" & Textbox1.text & ".lbe"
If Not fileexprint.FileExists Then
MsgBox("Soubor neexistuje")
printers = False
Else
fileprint.PrintThisfile()
printers = True
End If
End Function
End Class
第二类:
Public Class fileprint
Public Shared Function PrintThisfile()
Dim formname As Long
Dim FileName As String
On Error Resume Next
Dim X As Long
X = Shell(formname, "Print", FileName, 0&)
End Function
End Class
第三类:
Public Class fileexprint
Public Shared Function FileExists()
Dim fname As Boolean
' Returns TRUE if the file exists
Dim X As String
X = Dir(fname)
If X <> "" Then FileExists = True _
Else FileExists = False
End Function
End Class
当我用文本填充文本框时,如何使用此文本在计算机中搜索文件并打印此文件?
您的“Textbox1”是一个变量,实际上并没有从文本框中获取值。如果我没记错的话,我相信您打算获取文本框的值并连接以形成您的目录 url。您首先需要向 Windows/Web 表单添加一个文本框,为该文本框指定一个 id,然后在后面的代码中调用该 id。例如,您添加一个 ID 为“textbox001”的文本框,在您后面的代码中,您将执行类似“textbox001.text”的操作。在你的情况下,它现在是:strFile = "C:_Montix as - cloud\iMontix\Testy\" & textbox001.text & ".lbe"。希望这可以帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句