[RESOLVED] VBsript Left() Function.
Hello,
I'm new to visual basic, working on a school project.
I'm stuck with this part of my program:
Private Sub tramite_Change()
Dim ctrl, ctrlnum
numero_de_control.SetFocus
ctrl = numero_de_control.Value
ctrlnum = Left(ctrl, 3)
MsgBox (ctrlnum)
Text24.SetFocus
Text24.Text = Now()
End Sub
OK,
ctrlnum = Left(ctrl, 3)
Does not work, it returns "Compile error: Can't find project or library"
If I do this:
Left(ctrl, 3) = ctrlnum
It works but of course the ctrl string is modified with the value of ctrlnum, and what I need if to store the result of Left() function on ctrlnum.
Please help... :confused:
Re: VBsript Left() Function.
ctrl is a value, not an object. You might try
ctrlnum = Left(numero_de_control.Value, 3)
Re: VBsript Left() Function.
Welcome to the Forums. :)
Slightly off topic:
When you do: Dim ctrl, ctrlnum
Both of those are Variants...not strings; not integers, but Variants. Is this what you intended?
Re: VBsript Left() Function.
Thank's for your replies...
Now I have this, and still the same error.
Private Sub tramite_Change()
Dim ctrl, ctrlnum As String
numero_de_control.SetFocus
'ctrl = numero_de_control.Value
ctrlnum = Left(numero_de_control.Value, 3)
'ctrlnum = Left(ctrl, 3)
Text24.SetFocus
Text24.Text = Now()
End Sub
I have noticed something, when I move the function to the right of the equal sign, Left is no longer in blue letters, you know like when VB detects it is a function.
Has anyone had a problem like this before?
Re: VBsript Left() Function.
try this little change:
ctrlnum = Left(cstr(numero_de_control.Value), 3)
Re: VBsript Left() Function.
Thank's,
Tried that and still fails the same:
"Compile Errror: Can't find project or Library".
I tried Right(), Mid() functions and the same error occurs.
Could this be something with the version of access I have?
I'm working with:
Microsoft Access 2000, version 9.0.2720
Jorge.
Re: VBsript Left() Function.
Welcome to the forums jorge. :D
When posting code please use the format in Hacks signature.
Also, this:
VB Code:
Dim ctrl, ctrlnum As String
Declares ctrl as a variant ans ctrlnum as a string to make them both strings do the following:
VB Code:
Dim ctrl As String, ctrlnum As String
Re: VBsript Left() Function.
What is "numero_de_control"? A textbox?
ctrlnum = Left(numero_de_control.text, 3)
Re: VBsript Left() Function.
Sorry for that, I'll use that format in my next posts.
Yes, numero_de_control is a textbox.
Jorge.
Re: VBsript Left() Function.
So why doesn't the previous post work?
Re: VBsript Left() Function.
I really don't know, I'm very confused.
Re: VBsript Left() Function.
VB sometimes has this problem. It loses the reference to all the VBA functions (Left, Mid, Right etc..) even though the dll is still referenced. Usually closing VB down and reopening it does the trick.
Maybe it will work with Access too?
Re: VBsript Left() Function.
Well, I have been working on this for a couple of days and have turned off my computer, and still don't work.
Right now I'm downloading a Office SR-1 update (Sloooow) to see if this helps, I have been told that maybe I have a bad vbscript.dll file, I hope that this update fixes it.
Thank's.
Re: [RESOLVED] VBsript Left() Function.
Issue has been resolved, it turned out to be a ActiveX reference that was not registered, so you just go to Tools - Reference Menu on Visual Basic and uncheck the references marked a "MISSING", if your project does not use them it should run now, if your program does use it you'll have to re-register the reference, check the Microsoft MSDN archives for more info.
Thank's a lot for your help! :bigyello: