VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Convert VB6 to VB5 every time a project loads Updated version


Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

This program converts the VB6 project file to VB5, before opening VB to open the file. If the file is already VB5 compatible it will leave it alone. Compile the file to the same folder
where Vb5.exe is and then hold down SHIFT
while right clicking on a .vbp file. Choose Open with... then click on other and choose the file that you compiled. Now whenever you open a .vbp file it will convert it then allow VB to open it. NOTE: if there are more tags that are not VB5 compatible, please tell me. The old version did not work with project files that had a space in the path, but this version is compatible. If you like this app, please rate it.

Inputs
Call from windows
Assumes
When you compile it the .exe file needs to be in the same folder as Vb5.exe and this only works when the file is opened from Windows. If you open the file in VB itself, the conversion will not take place.
Code Returns
A call to VB
Side Effects
None that I know of

Rate Convert VB6 to VB5 every time a project loads Updated version

' Make a project with only a module and put this
' in it:
Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Public Function GetShortPath(strFileName As String) As String
 Dim lngRes As Long, strPath As String
 strPath = String$(165, 0)
 lngRes = GetShortPathName(strFileName, strPath, 164)
 GetShortPath = Left$(strPath, lngRes)
End Function
Public Function GetPathAndFileName(ByVal PathAndFileName, ByRef FileName As String) As String
 Dim lPos As Long
 Dim lLastPos As Long
 
 lPos = InStr(1, PathAndFileName, "\")
 While lPos <> 0
 lLastPos = lPos
 lPos = InStr(lLastPos + 1, PathAndFileName, "\")
 Wend
 
 GetPathAndFileName = Left(PathAndFileName, lLastPos - 1)
 FileName = Mid(PathAndFileName, lLastPos + 1)
 
End Function
Sub Main()
 On Error Resume Next
 Dim property As String
 Dim newfile As String
 Open Command For Input As #1
 Do Until EOF(1)
 Line Input #1, property
 If property = "Retained=0" Then
 Else
 If property = "Retained=1" Then
  Else
  If property = "DebugStartupOption=0" Then
  Else
  If property = "DebugStartupOption=1" Then
   Else
   newfile = newfile & property & vbCrLf
  End If
  End If
 End If
 End If
 Loop
 Close #1
 Open Command For Output As #1
 Print #1, newfile
 Close #1
 Dim RetVal
 Dim Path As String
 Dim File As String
 Dim ShortPath
 Dim apppath, cmdline
 If Len(App.Path) <> 2 Then 'if path is not root, add a "\"
 apppath = App.Path & "\"
 Else
 apppath = App.Path
 End If
 Path = GetPathAndFileName(Command, File)
 ShortPath = GetShortPath(Path)
 cmdline = apppath & "Vb5.exe " & ShortPath & "\" & File
 RetVal = Shell(cmdline, vbNormalFocus)
 End
End Sub

Download this snippet    Add to My Saved Code

Convert VB6 to VB5 every time a project loads Updated version Comments

No comments have been posted about Convert VB6 to VB5 every time a project loads Updated version. Why not be the first to post a comment about Convert VB6 to VB5 every time a project loads Updated version.

Post your comment

Subject:
Message:
0/1000 characters