|
-
Jul 8th, 2005, 12:56 PM
#1
Thread Starter
New Member
[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...
-
Jul 8th, 2005, 01:07 PM
#2
PowerPoster
Re: VBsript Left() Function.
ctrl is a value, not an object. You might try
ctrlnum = Left(numero_de_control.Value, 3)
-
Jul 8th, 2005, 01:17 PM
#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?
-
Jul 8th, 2005, 01:40 PM
#4
Thread Starter
New Member
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?
-
Jul 8th, 2005, 01:42 PM
#5
PowerPoster
Re: VBsript Left() Function.
try this little change:
ctrlnum = Left(cstr(numero_de_control.Value), 3)
-
Jul 8th, 2005, 02:16 PM
#6
Thread Starter
New Member
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.
-
Jul 8th, 2005, 02:16 PM
#7
Re: VBsript Left() Function.
Welcome to the forums jorge. 
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
-
Jul 8th, 2005, 02:19 PM
#8
PowerPoster
Re: VBsript Left() Function.
What is "numero_de_control"? A textbox?
ctrlnum = Left(numero_de_control.text, 3)
-
Jul 8th, 2005, 02:39 PM
#9
Thread Starter
New Member
Re: VBsript Left() Function.
Sorry for that, I'll use that format in my next posts.
Yes, numero_de_control is a textbox.
Jorge.
-
Jul 8th, 2005, 02:43 PM
#10
PowerPoster
Re: VBsript Left() Function.
So why doesn't the previous post work?
-
Jul 8th, 2005, 03:23 PM
#11
Thread Starter
New Member
Re: VBsript Left() Function.
I really don't know, I'm very confused.
-
Jul 8th, 2005, 03:29 PM
#12
Fanatic Member
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?
-
Jul 8th, 2005, 03:58 PM
#13
Thread Starter
New Member
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.
-
Jul 12th, 2005, 09:14 AM
#14
Thread Starter
New Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|