Jump to content

Hey Guys Need A Little Help In Vb :(


Recommended Posts

it's been ages since i was here kinda got lost in the whole idea of learning to programme i've run into a wall and i can't get out of it at all, i was wondering if some of you can help me

Problem:

i get an error that says Compile error: The argument is not optional

i've attatched a .ace file with all the .frms and .vbp files

the problem occurs on the customer.frm when you click the save button.

Any help will be greatly appreciated :)

Share this post


Link to post
Share on other sites

I'd love to try and help, but it seem some files are missing. When I tried opening the project it couldn't find modmain.bas and opening the form want a procedure called "CheckLogin".

Share this post


Link to post
Share on other sites

Well, I am at Uni and they only have .NET mooness.. but here's my take on it.

 

If Len(txtFirstName) <= 0 Then

 

and

 

If Len(LastName) <= 0 Then

 

Should probably read..

 

If Len(txtFirstName.text) <= 0 Then

 

and

 

If Len(LastName.text) <= 0 Then

 

With .NET it's some Java like ToString thing they're using, so I can't test it really.. but that's my guess.

Edited by markiemrboo

Share this post


Link to post
Share on other sites

What MarkieMrBoo suggested is recommended but not required in VB6. It is good programming style and I would do what he suggested.

 

However, to fix the problem you can do one of two things.

 

First, it appears you have made the text box controls txtFirstName and LastName members of a control array. To fix your code try this:

 

If Len(txtFirstName(0).Text) <= 0 Then

and

If Len(LastName(1)) <= 0 Then

 

or you can recreate the text box control and don't make them arrays (I suspect you did a copy and paste of one text box to another maybe?)

 

 

Also, as a suggestion, it is good style to use consistent names for your controls, so "LastName" should be "txtLastName".

 

My suggestion is to delete these controls, recreate them without using a copy/paste.

 

Hint: Look at the properties of the controls and find the Index property. It should be blank if you are not using a control array.

Share this post


Link to post
Share on other sites

awww cheers guys thats helped out a big lot, and about being consisten, normally i am but i got so frustrated with it i started changing all sorts of captions and names and the lot, i'm sure y'kno how it is. lol. Just one more minor niggle it doesnt appear to be working for the second msg box the code that says

if Len(txtLastName.Text) <=0 Then

msgbox "Last Name is required to save changes", vbExclamation

End if

so i was thinking maybe this is because the two if....then statements aren't linked together in any way, is there a way i could link them together? perhaps using elseif?

 

 

 

EDIT: no worries on the minor niggle, i got rid of the first exit sub and it works a treat, brilliant

you guys are ace how can i ever thanK you enough?

Share this post


Link to post
Share on other sites

Glad that you got it working.

 

I can't remember exactly but I don't think you needed either of the Exit Sub's :)

 

You can link If statements, as you put it, by using an Else.

 

If (expression) Then
  ' Do some stuff
Else If (expression2) Then
  ' Do some totally different stuff
End If

 

or maybe it was elseif ... I dunno, my VB is very rusty to say the least :)

Share this post


Link to post
Share on other sites

Glad that you got it working.

 

I can't remember exactly but I don't think you needed either of the Exit Sub's :)

 

You can link If statements, as you put it, by using an Else.

 

If (expression) Then

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...