那只是一个文件选择的对话框
需要你自己写代码处理
读取:
Dim TempFile As Long
Dim LoadBytes() As ByteTempFile=FreeFile
Open 文件名 For Binary As #TempFile
Redim LoadBytes(1 To Lof(TempFile)) As Byte
Get #TempFile,,LoadBytes
Close TempFileText1.Text=StrConv(LoadBytes,vbUniCode)

解决方案 »

  1.   

    加个commondialog控件,用SHOWOPEN方法,会弹出打开对话框,选中文件后返回filename属性。这个只是文件路径,要打开语句如下:
    dim FP as interger
    dim strTemp as stringFP=freefile
    open commondialog1.filename for input as #fp
      do until eof(fp)
         line input #fp,strtemp
         text1.text=text1.text & vbnewline & strtemp
      loop
    close #fp
      

  2.   

    CommonDlg.ShowOpen
    text.text=CommonDlg.FileName
      

  3.   


    这个我知道了
    不过,我在调试的时候,
    open 文件名 for..
    这个文件名可以用变量吗?
    我用个变量调试怎么不行啊?
      

  4.   

    文件名随你写啊如:
    Open "c:\1.txt" For Binary As #TempFile
      

  5.   

    调用API实现的:Public Declare Function GetOpenFileName _
            Lib "comdlg32.dll" Alias "GetOpenFileNameA" _
            (pOpenfilename As OPENFILENAME) As LongPublic Type OPENFILENAME
        lStructSize As Long
        hwndOwner As Long
        hInstance As Long
        lpstrFilter As String
        lpstrCustomFilter As String
        nMaxCustFilter As Long
        nFilterIndex As Long
        lpstrFile As String
        nMaxFile As Long
        lpstrFileTitle As String
        nMaxFileTitle As Long
        lpstrInitialDir As String
        lpstrTitle As String
        flags As Long
        nFileOffset As Integer
        nFileExtension As Integer
        lpstrDefExt As String
        lCustData As Long
        lpfnHook As Long
        lpTemplateName As String
    End Type
    Public Const OFN_HIDEREADONLY = &H4 '隐藏只读打开
    Public Const OFN_READONLY = &H1 '只读打开为选中
    Public Const OFN_OVERWRITEPROMPT = &H2 '覆盖时提示
    Public Const OFN_ALLOWMULTISELECT = &H200 '多个选中
    Public Const OFN_EXPLORER = &H80000 '资源管理器Public Function ShowOpen(MehWnd As Long, _
            FileOpen As String, _
            Optional Title As String = "打开:", _
            Optional Filter As String = vbNullChar + vbNullChar, _
            Optional FilterIndex As Long = 0, _
            Optional StartDir As String = vbNullChar, _
            Optional flags As Long = OFN_HIDEREADONLY) As Long
        Dim OpenFN As OPENFILENAME
        Dim Rc As Long
        
        With OpenFN
            .hwndOwner = MehWnd
            .hInstance = App.hInstance
            .lpstrTitle = Title
            .lpstrFilter = Filter
            .nFilterIndex = FilterIndex
            .lpstrInitialDir = StartDir
            .lpstrFile = String$(256, 0)
            .nMaxFile = 255
            .lpstrFileTitle = .lpstrFile
            .nMaxFileTitle = 255
            .flags = flags
            .lStructSize = Len(OpenFN)
            
        End With
        
        Rc = GetOpenFileName(OpenFN)
        
        If Rc Then
            FileOpen = Left$(OpenFN.lpstrFile, OpenFN.nMaxFile)
            ShowOpen = True
            
        Else
            ShowOpen = False
            
        End If
        
    End Function调用:
    Dim strFileName as stringIf ShowOpen(Me.hWnd, strFileName) Then
        Open strFileName For Binary As #TempFile
        ……
    End If
      

  6.   

    共用对话框是VB自带的控件(实际上是操作系统带的),怎么会没有呢
    由VB就有
      

  7.   

    Open的文件名当然可以用变量
    文件号最好定义一个变量
    用FreeFile获取
      

  8.   

    把“调用:”前的那段代码放在“模块”中“调用:”后的那段代码那段可以放在 你的窗体上的CommandButton的Click事件中
      

  9.   

    操作系统带的是comdlg32.dll!而不是comdlg32.ocx!!!
      

  10.   

    具体是哪个控件
    是打开(open)控件啊
    无论是系统带的还是VB带的
    可以指出来吗?