在我的机器上的vb上能调试程序,但是在我同学和老师的机器上有错误。
不过演示错误,下面:
Sub Main()
    
    Dim objName As New CIniOperate
    Dim strIniPath As String
     
    strIniPath = App.Path & "\ini\MIS.ini"
    objName.SpecifyIni (strIniPath)
  ********  If Trim$(objName.ReadString("Mis_sec2", "FirstRun", 6)) = "true" Then
          FrmConfig.Show vbModal
          If objName.WriteString("Mis_sec2", "FirstRun", "false") = False Then
              MsgBox "错误:" & objName.ErrorMsg, vbOKOnly + vbExclamation, "警告"
          End If
          
    End If
    
    strSvrName = Trim$(objName.ReadString("Mis_sec1", "SvrName", 20))
    strSuperPwd = Trim$(objName.ReadString("Mis_sec1", "Password", 20))
    frmLogin.Show vbModal
    If Not frmLogin.LoginSucceeded Then
        End
    End If
    
       
    MDIMain.Show
End Sub
其中 Dim objName As New CIniOperate使我自个定义的类,用来读写 ini文件。
上面打星号的有错误!!!
  错误显示:compile error:
Can't find project or library。

解决方案 »

  1.   

    读INI不至于还要自己写个类吧,调API就可以嘛
      

  2.   

    用API当然方便了~~
    代码如下
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
    Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As LongPrivate Sub Form_Load()
        Open "C:\aa.ini" For Output As #1
        Print #1, "文件内容"
        Close #1
    End SubPrivate Sub Label1_Click()
    On Error GoTo Errhandle
        ShellExecute Me.hwnd, "open", "www.sohu.com", vbNullString, vbNullString, 1
        Exit Sub
    Errhandle:
        MsgBox Err.Description & "!", vbInformation
    End Sub'写INI文件
    Private Sub Command1_Click()
        Dim Counter As Long    For Counter = 1 To 4
            Call WriteToIni(App.Path & "\Options.ini", "Test", "Name" & Counter, "Value" & Counter)
        Next Counter
    End Sub'读INI文件
    Private Sub Command2_Click()
        Dim Counter As Long
        Dim Value(3) As String    For Counter = 1 To 4
            Value(Counter - 1) = ReadFromIni(App.Path & "\Options.ini", "Test", "Name" & Counter)
        Next Counter
    End Sub
      

  3.   

    把这个类拷贝到system32目录下面,打开命令提示符,转到相应目录下面,输入:
    regsvr32 你的dll名.dll
      

  4.   

    那时 类模板不是dll文件呀。后缀名为.cls.....
      

  5.   

    你同学和教师的机器上有一些引用丢失   VB 菜单 [工程]->[引用]  在弹出的窗口中找有没有 "丢失"2字 想办法加上丢失的对象有没事了
      

  6.   

    错误显示在trim这个函数上的!!
      

  7.   

    没错就是我说的,就是会报在 Trim left right .....系统函数上
      

  8.   

    例如将丢失的对象勾掉 然后 在找到该对象重新加上引用即可
    你也可以做个实验,在一台安装了 office2000的机器上引用 microsoft excel 9.0 然后将该团软件源程序拷贝到一台安装了 office97 的机器上 就会发现 microsoft excel 9.0 丢失,那是因为office97 带的是 microsoft excel 8.0 这时你的系统运行时 所有的系统函数都会报有错 (trim   left   right  instr  cint ......)
      

  9.   

    是不是要引用microsoft scripting runtime?
      

  10.   

    谢谢,但是不太明白。
    错误提示:
    compile error:
    Can't find project or library。
    他没告诉我那个库呀。不知如何是号
      

  11.   

    而且他们中装的是windows xp和office xp
    而我装的是windows 2000和office 200!!
      

  12.   

    把trim换成VBA.Trim,其它left right同样处理,我在一个朋友的机子上遇到过这种情况,他的vb盘太次,我让他换了一张装,就OK了。
      

  13.   

    我的是windows 2000 server!!