Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running VB6 under VB5

Status
Not open for further replies.

Lena

Programmer
Sep 24, 1998
2
0
0
US
Has anyone created a new project under VB6 and then run it under VB5? Is it possible to do so? I would like to install the newer version at home, but they will be using the older one at school for some time. TIA
 
Considering previous history, this is probably not doable. The enhancements in VB6 will be such that the VB5 runtimes won't work, and the VB5 IDE won't have the capability to load those enhancements. Sorry.
 
I think Yes. However, you will get an error at startup in VB5. It's easily resolved by deleting the bad code that will be at the top of one of your modules. Important Though........ I had a problem creating an executable. When I install the VB5 project on the target system, I got an error (error number 3447 I think). Had something to do with opening the database (sorry I don't have exact error text). MS KB has info on this and there is no resolution other than not running both versions on the same system.
 
I never tried this before, but I would like share my most-humble-opinion that this is really not recommended.<br>
<br>
You may end-up after coding a huge section but it becomes unreadable in another version. Bear in mind that you are using Microsoft products. Maybe I am bit out-of-date, thought I haven't heard anything VB6 has such feature officially.
 
OK, folk, let's get practical. Load a VB5 project into VB6. If VB6 tells you that the form(s)/module(s) will be upgraded, then you can't run the two interchangeably. If the VB6 instalation replaces any VB5 core libraries, then the two will not run side by side. You can split hairs and probably produce something that will make that statement a lie, but to all real world intents and purposes, the two products will not run side by side: see Misled's comment in a previous post regarding a database error. That error was due to compiling an app in VB5 on a machine that had VB6 installed. One of the core libraries was upgraded, and is not compatible with VB5 functionality.
 
What's more......when VB5 loaded (and 'converted" VB4 applications), it changed several of my controls to "picturebox" controls 9didn't bother to tell me that it had done this, BTW). Apparently (acc. to PC mag.), the beta of VB6 had the same problem. I don't know whether this was fixed on the official release. But, I would certainly NOT RECOMMEND trying to do this. Does MS VB6 license allow you to install VB6 at home if you have VB6 at work ??
 
I've done this more than onece with no problems. I suppose it varies from programme to programme whether you will have any difficulty. You will have to remove a line from the vb6 project file to get it to load in vb5, retained = true, I think.
 
To Petermeachem
'Retained=0'

You can Convert a VB6 project to VB5 :

a TextBox multiline = True and OleDragmode Automatique

(the text : drag your vb6 project file
into this box to change it to vb5 )

Form declarations (no options Explicit)

Const ChunkSize = 4096

a Function :
Private Function FindInString(StartPos As Integer, StrToSearch As String, _
StrToFind As String) As Integer
If Check1.Value = 0 Then
FindInString = InStr(StartPos, UCase(StrToSearch), UCase(StrToFind))
Else
FindInString = InStr(StartPos, StrToSearch, StrToFind)
End If
End Function

a procedure :

Public Sub vb6tovb5(FName$, IDString$, NString$)
Dim tempstring, Msg
Dim PosString, WhereString
Dim FileNumber, A$, NewString$
Dim AString As String * ChunkSize
Dim IsChanged As Boolean
Dim BlockIsChanged As Boolean
Dim NumChanges As Integer
IsChanged = False
BlockIsChanged = False
On Error Resume Next
FileNumber = FreeFile
PosString = 1
WhereString = 0
AString = Space$(ChunkSize)
'Make sure strings have same size
If Len(IDString$) > Len(NString$) Then
NewString$ = NString$ + Space$(Len(IDString$) - Len(NString$))
Else
NewString$ = Left$(NString$, Len(IDString$))
End If
Open FName$ For Binary As FileNumber
NumChanges = 0
If LOF(FileNumber) < ChunkSize Then
A$ = Space$(LOF(FileNumber))
Get #FileNumber, 1, A$
WhereString = FindInString(1, A$, IDString$)
Else
A$ = Space$(ChunkSize)
Get #FileNumber, 1, A$
WhereString = FindInString(1, A$, IDString$)
End If
Do
While WhereString <> 0
tempstring = Left$(A$, WhereString - 1) & NewString$ & Mid$(A$, WhereString + Len(NewString$))
A$ = tempstring
NumChanges = NumChanges + 1
IsChanged = True
BlockIsChanged = True
WhereString = FindInString(WhereString + 1, A$, IDString$)
Wend
If BlockIsChanged Then
Put #FileNumber, PosString, A$
BlockIsChanged = False
End If
PosString = ChunkSize + PosString - Len(IDString$)
' If we're finished, exit the loop
If EOF(FileNumber) Or PosString > LOF(FileNumber) Then
Exit Do
End If
' Get the next chunk to scan
If PosString + ChunkSize > LOF(FileNumber) Then
A$ = Space$(LOF(FileNumber) - PosString + 1)
Get #FileNumber, PosString, A$
WhereString = FindInString(1, A$, IDString$)
Else
A$ = Space$(ChunkSize)
Get #FileNumber, PosString, A$
WhereString = FindInString(1, A$, IDString$)
End If
Loop Until EOF(FileNumber) Or PosString > LOF(FileNumber)
If IsChanged = True Then
MsgBox FName$ & &quot; is now compatible with VB5&quot;, vbInformation, &quot;File converted to VB5&quot;
Else
MsgBox &quot;File has not been converted to VB5&quot;, vbCritical, &quot;Could not convert&quot;
End If
End Sub

Private Sub Text1_OLEDragDrop(data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
Dim file
If data.GetFormat(vbCFFiles) Then
For Each file In data.Files
If UCase(Right(file, 4)) = UCase(&quot;.vbp&quot;) Then
Text4.Text = file
vb6tovb5 Text4.Text, Text2.Text, Text3.Text
Else
MsgBox &quot;Make sure the file extension is .vbp!&quot;, vbCritical, &quot;Error&quot;
End If
Next file
Else
MsgBox &quot;Other Error, Please make sure it is a vb Project!!!&quot;, vbCritical, &quot;Error&quot;
End If
End Sub

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX.

Download Demo version on my Site:
Promotions before 02/28/2001 (free source codebook),visite my site
 
cripes, whats all that about. Today I sent off an update to a customer that didnt work. It was a vb5 programme that I had inadvertantly loaded in VB6. So I removed the retained = line, compiled it in vb5 and sent it off. All ok.
Ive just tried it with another vb6 programme. It loaded OK then would not work because of an ADO problem, which is ok.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top