Results 1 to 14 of 14

Thread: [RESOLVED] VBsript Left() Function.

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    Resolved [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...

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: VBsript Left() Function.

    ctrl is a value, not an object. You might try

    ctrlnum = Left(numero_de_control.Value, 3)

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    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?

  5. #5
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: VBsript Left() Function.

    try this little change:

    ctrlnum = Left(cstr(numero_de_control.Value), 3)

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    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.

  7. #7
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: VBsript Left() Function.

    Welcome to the forums jorge.

    When posting code please use the format in Hacks signature.

    Also, this:

    VB Code:
    1. 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:
    1. Dim ctrl As String, ctrlnum As String
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  8. #8
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: VBsript Left() Function.

    What is "numero_de_control"? A textbox?

    ctrlnum = Left(numero_de_control.text, 3)

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    Re: VBsript Left() Function.

    Sorry for that, I'll use that format in my next posts.

    Yes, numero_de_control is a textbox.

    Jorge.

  10. #10
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: VBsript Left() Function.

    So why doesn't the previous post work?

  11. #11

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    Re: VBsript Left() Function.

    I really don't know, I'm very confused.

  12. #12
    Fanatic Member Blade's Avatar
    Join Date
    Jan 1999
    Location
    Stoke-on-Trent, UK
    Posts
    527

    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?

  13. #13

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    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.

  14. #14

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    Resolved 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
  •  



Click Here to Expand Forum to Full Width