Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » Classic Visual Basic (VB 6 or earlier) » General Visual Basic » Runtime error '5'

13 posts, Page 1 of 2. 12»»

Runtime error '5'Expand / Collapse
Author
Message
Posted 11/1/2004 6:02:28 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 11/15/2004 10:27:00 PM
Posts: 16, Visits: 1
Hi Guys,

Hows it going?


I have a bit of a problem, in that I have developed a VB6 application which works perfectly well on the machine I programmed it on.

However, when I run it on another PC,, also running Win XP professional, it gets runtime error '5' and shuts down.

The main problem is, I cant tell exactly what the code is, as VB isn't on the other machine. I dont want to put VB on it either as I am using that machine to simulate what would happen when the client is to run this program.

I have tried downloading a file from microsoft called VBrun60.exe, but it makes no difference.


I am in the process of narrowing down the code where the error occurs, and will post this when I find it.




in the meantime, does anyone have any ideas on this?

Thanks heaps.

Post #5632
Posted 11/1/2004 6:41:44 PM
Forum God

Forum God

Group: Moderators
Last Login: Yesterday @ 1:42:32 PM
Posts: 1,073, Visits: 9,408
Its kind of hard to tell without seeing the source code. If you want to post it you would probably get your answer.
Post #5634
Posted 11/1/2004 7:34:47 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 11/15/2004 10:27:00 PM
Posts: 16, Visits: 1

What I have done is put a message box with a number after every line of code to show me where it gets up to.

This code is executed when the login button is hit:

If userset("password") = (omd5.MD5(txtPassword.Text)) Then
txtUserName.Text = Replace(txtUserName.Text, "_", " ")

Login.Hide

existingReportFlag = False
MsgBox ("1")
MainMenu.Show
MsgBox ("2")
Else

MsgBox ("3")
MsgBox "Failed to open the database!" & vbCrLf & vbCrLf & "Please ensure that you are a user of the database and that the user name and password typed is correct", vbCritical, "Connection failed"
txtUserName.SetFocus
End If

MsgBox ("4")

Exit Sub


I get message box "1", before the crash, so I can assume it has something to do with loading the main menu.

this is the form_load of the main menu:

Private Sub Form_Load()
MsgBox ("8")
' disable this form's close button ('X') to prevent user from exiting system unsafely (without closing connection to the database)
DisableX Me

' do not allow user to add new reports, upload offline report files or add new clients

MsgBox ("9")
If LCase(Login.txtUserName.Text) <> "xxxx" And LCase(Login.txtUserName.Text) <> "xxxx" Then
cmdOpenSearch.Caption = "View Report"
MsgBox ("10")
cmdAddReport.Enabled = False
cmdUploadReport.Enabled = False
cmdAddClient.Enabled = False
MsgBox ("11")
End If


' setting properties of the 'Upload an offline report' common dialog box (&H1000& - handles non-existant files, &H4& - hides read only check box, &H800& - handles incorrect paths, &H100& - allows file names with invalid characters, &H40000 - do not use long file names
MsgBox ("12")
CommonDialog2.Flags = &H1000& Or &H4& Or &H800& Or &H100& Or &H40000
MsgBox ("13")
' insert icons into this form and the command buttons 'Add New Report', 'Edit/Print Report', 'Upload Offline Report', 'Add New Client' and 'Exit System'
MainMenu.Icon = LoadPicture("C:\NDS\Report\Icons\NETHOOD.ico")
... (loads more icons)
cmdExit.Picture = LoadPicture("C:\NDS\Report\Icons\PC07J.ico")
MsgBox ("14")

End Sub

I dont even get the message box '8' to appear.

the only possible line of code it can crash on is mainmenu.show

I dont get it.
Post #5635
Posted 11/2/2004 4:58:25 AM


Forum God

Forum GodForum GodForum GodForum GodForum GodForum GodForum GodForum God

Group: Forum Members
Last Login: 1/27/2008 2:50:27 PM
Posts: 334, Visits: 16

make sure you have the common dialog dll in your system folder.  (C:\WINDOWS\system\COMMDLG.DLL on my computer)

Have you installed the runtime files on the machine?



Milo

Milo!

Post #5650
Posted 11/2/2004 10:26:41 AM


Forum God

Forum GodForum GodForum GodForum GodForum GodForum GodForum GodForum God

Group: Forum Members
Last Login: 1/12/2006 7:37:05 AM
Posts: 712, Visits: 6
vb programs are not standalone, and as milo says you need the common dialog control for your code to work. best off making a setup file which will include all needed dependancies and register them when the user installs your app.

inno is popular but doesn't scan projects itself, where setup factory does but isn't free. personally i use inno...

http://www.jrsoftware.org/isinfo.php

and this to check for dependancies (you can copy the required lines from the generated script and add to your own ino script)...

http://www.randem.com/innoscript.html




API Guide - VB/MySQL - W3Schools - WinsockVB
Post #5673
Posted 11/2/2004 6:15:01 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 11/15/2004 10:27:00 PM
Posts: 16, Visits: 1
Hi

Thanks for your help. I have downloaded that inno, but I stull dont know what files are needed.

I have put the ocx, dll and runtime files on the computer and still it wont work. commdlg.dll is in both system and system32 directores.

By runtime files, I downloaded vbrun60.exe. I think that is correct.

any ideas on what I could be missing?
Post #5697
Posted 11/2/2004 7:48:15 PM
Forum God

Forum God

Group: Moderators
Last Login: Yesterday @ 1:42:32 PM
Posts: 1,073, Visits: 9,408

From what I gather from what you are saying is that you copied the app to a new machine. The app will start but when you click a button that should open a new form, the app dies.

If this is correct, I would say the target machine already has the runtimes that are required to run a VB app. I don't see anything in the little bit of code that should cause the app to die when you try openning a new form. With that in mind I would guess that something that you are doing someplace else is  causing the problem.

Why don't you try zipping the entire project and post that. It may be easier to debug that.

Post #5699
Posted 11/2/2004 9:00:01 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 11/15/2004 10:27:00 PM
Posts: 16, Visits: 1
I'd probably rather avoid putting it on here at the moment, as you would have to log into a database on this machine.

Do you have any suggestions as to what sort of things I should be looking for in other places that might be causing problems?
Post #5700
Posted 11/2/2004 9:32:28 PM
Forum God

Forum God

Group: Moderators
Last Login: Yesterday @ 1:42:32 PM
Posts: 1,073, Visits: 9,408
Kind of hard to guess. Aside from what you have shown so far what else happens befor calling MainMenu.Show?
Post #5703
Posted 11/2/2004 9:49:44 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 11/15/2004 10:27:00 PM
Posts: 16, Visits: 1
Yeah sorry to be so difficult.. just not sure of security issues yet.

anyway, this is all the code before it gets to mainmenu.show



Dim file As String

file = "C:\xxxx"


Open file For Output As #1

Print #1, txtip.Text



Close #1

ipaddress = txtip.Text

On Error GoTo Err_cmdLogin_Click


' ensure user provides user name and password before login attempt
If txtUserName.Text = "" And txtPassword.Text = "" Then
MsgBox "You must enter a user name and password!", vbExclamation, "Enter User Name and Password"
txtUserName.SetFocus
Exit Sub
ElseIf txtUserName.Text = "" Then
MsgBox "You must enter a user name!", vbExclamation, "Enter User Name"
txtUserName.SetFocus
Exit Sub
ElseIf txtPassword.Text = "" Then
MsgBox "You must enter a password!", vbExclamation, "Enter Password"
txtPassword.SetFocus
Exit Sub
End If

Set connection = New ADODB.connection

connection.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=" & ipaddress & ";" & _
"DATABASE=NDS;" & _
"UID=" & dusername & ";PWD=" & dpassword & "; OPTION=3"

' open connection to the nds database
connection.Open


Dim strsql As String, s1 As String, s2 As String
Dim omd5 As CMD5

Set omd5 = New CMD5
strsql = "Select * from user where username = '" & txtUserName.Text & "'"

Set userset = connection.Execute(strsql)



If userset("password") = (omd5.MD5(txtPassword.Text)) Then




' having connected to the database, replace underscores in the user name with spaces (to allow searching and labelling), close the Login form, set the flag and open the Internal/External Report form
txtUserName.Text = Replace(txtUserName.Text, "_", " ")

Login.Hide

existingReportFlag = False
MsgBox ("1")
MainMenu.Show
MsgBox ("2")

Post #5704
« Prev Topic | Next Topic »

13 posts, Page 1 of 2. 12»»

Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod, Mark, Keithuk

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 3:46am