我正在尝试学习如何打开文件,并使用公共对话框将其内容放在TextField中,只使用Visual Basic 6中的命令对话框。
我需要使用一个常见的对话框,因为我试图在eVB中执行相同的应用程序,而eVB不支持这样的东西,这使得VB6开发更简单:
Dim objFSO As New Scripting.FileSystemObject
Dim objStream As Scripting.TextStream
答案 0 :(得分:1)
结帐eVB File Access through the WinCE API。文章中的示例代码(假设您已经从公共对话框中获取了文件名(myFileName)):
Public Const GENERIC_READ As Int32 = &H80000000
Public Const OPEN_EXISTING As Int32 = 3
' CreateFile will open a file handle (hFile) to the file in the myFileName variable
hFile = CreateFile(myFileName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)
lFileSize = GetFileSize(hFile, 0)
' String(lFileSize, 0) will prepare the sContents string variable
' to hold the contents of the file
sContents = String(lFileSize, 0)
' ReadFile actually reads the file we opened earlier and puts the contents
' into the sContents variable
ReadFile hFile, sContents, lFileSize, dwRead, 0
' Put the contents we read into the textbox
myTextBox.Text = sContents