Solved

I have a problem in vb code

Posted on 2007-11-26
4
721 Views
Last Modified: 2013-11-25
I have a problem in this line
error ( Compile error: Can't find project or library)
strFile = Input(LOF(1), #1)



Private Sub Form_Load()
   'Use icon of MDI form
   Me.Icon = mdiMain.Icon

    On Error GoTo sonali
    Dim strFile As String
    Dim arrFile
    Dim strDatabase As String
    Dim arrDatabase
   
   If Dir(App.Path + "\serverpath.txt") <> "" Then
   Open App.Path + "\serverpath.txt" For Input As #1
       strFile = Input(LOF(1), #1)
       arrFile = Split(strFile, ",")
       ServerPath = arrFile(0)
       MailIPAddress = arrFile(1)
       MailPort = arrFile(2)
       SQLServer = arrFile(3)
       SQLUID = arrFile(4)
       SQLPWD = arrFile(5)
   Close #1
   Else
       ServerPath = App.Path + "\"
       MailIPAddress = "192.168.0.100"
       MailPort = "25"
       SQLServer = "p4server"
       SQLUID = "rajesh"
       SQLPWD = "test"
   End If
   
    Open ServerPath & "\Databases.txt" For Input As #2
        strDatabase = Input(LOF(2), #2)
        arrDatabase = Split(strDatabase, vbCrLf)
        For i = 0 To UBound(arrDatabase)
            If Trim(arrDatabase(i)) <> "" Then
                lstDatabases.AddItem Trim(arrDatabase(i))
            End If
        Next i
    Close #2
    lstDatabases.Selected(lstDatabases.ListCount - 1) = True
   
   Exit Sub
sonali:
    If Err.Number = 53 Then  '* file not found
        urmila = MsgBox(" Please place Serverpath.txt In folder " & App.Path, vbInformation)
        Unload Me
        End
        Exit Sub
    End If
   
    If Err.Number = 52 Then  '* file not found
        urmila = MsgBox(" Please check your network connection and " & vbCrLf & "make sure that the database server is running.", vbInformation)
        Unload Me
        End
        Exit Sub
    End If
   
    MsgBox Err.Number & vbCrLf & Err.Description, vbOKOnly + vbCritical
   
End Sub
0
Comment
Question by:sitg
4 Comments
 

Author Comment

by:sitg
ID: 20349152
Pls help me
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20349203
You probably have a missing library in your project's references.

From the Project menu, choose References...
If one of the ticked libraries has the word 'Missing', remove the tick if it is not being used. If it is definitely needed, you will have to find the file on your computer.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 20349335
replace this line

strFile = Input(LOF(1), #1)

with

strFile = Space$(LOF(1))
Get #1, , strFile
0
 
LVL 17

Accepted Solution

by:
Shanmuga Sundaram earned 500 total points
ID: 20359914
EDDYKT,

strFile = Input(LOF(1), #1)

seems to be working. I think GrahamSkan is correct. Also Please note sitg, dont disclose your usernames and passwords in public. if any of your employees comes to know about this they can view your database.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 103
I need help formating a date variable in my VB.Net application 2 44
Excel VBA, find a string in a column, update a cell 7 66
Child Form in front 4 38
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now