Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB5,VB6
Expertise: Intermediate
May 20, 2000

Convert a VB6 project back to VB5

If you load a VB6 project file in the VB5 environment you get a warning, even though the project is correctly loaded. The cause of the warning is a VB6 attribute "Retained" (that is, the "Retained in memory" option in the Project Properties dialog box) that isn't recognized by VB5. If you want to make a VB6 .vbp file backward campatibile with VB5 you can convert it using the following routine:

' Convert a VB6 VBP file so that it can be read
' into VB5 IDE without any error
'
' Returns True if successful,
' False if the project was already in VB5 format

Function ConvertVB6Project(ByVal filename As String) As Boolean
    Dim fnum As Long
    Dim fileText As String
    Dim i As Long
    
    fnum = FreeFile
    ' if the file doesn't exist, this statement raises an error
    Open filename For Input As #fnum
    ' read the entire fire and close it
    fileText = Input$(LOF(fnum), fnum)
    Close #fnum
    
    ' strip the "Retained" attribute
    ' we could easily delete it using the Replace function
    ' but we want this function to work under VB5 as well
    ' for obvious reasons
    i = InStr(1, fileText, "Retained=", vbTextCompare)
    ' if not found this is a VB5 project file
    If i = 0 Then Exit Function
    
    ' delete this line (account for the CRLF)
    fileText = Left$(fileText, i - 1) & Mid$(fileText, _
        i + Len("Retained=0") + 2)
    
    ' save to the same file
    Open filename For Output As #fnum
    Print #fnum, fileText;
    Close #fnum
    
    ' signal success
    ConvertVB6Project = True

End Function
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date