Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Right text function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Francis Brown - 22 Jan 2006 14:48 GMT
nYear = CLng(Right(TextBox3.Text, 4))

Could anyone tell me why the above code works in some excel versions yet in
others it does not.

xl 97 at work keels over yet mine does not.
Signature

Regards and Thanks for any assistance.

Francis Brown.

Dave Peterson - 22 Jan 2006 15:05 GMT
How does it fail?

If it fails on the Right() or CLng() portion, it could be caused by a missing
reference.

Open up one of those workbooks that won't work (on the failing pc).
Go into the VBE and select your project.

Then click on Tools|References

Look for MISSING in that list.

A missing reference will cause the procedure to not compile--and might point at
any old line.

Once you find that missing reference, you'll either have to deselect it or find
what it is and correct it.

=====
Or could it be as simple as that textbox3.text didn't have 4 digits at the far
right???

> nYear = CLng(Right(TextBox3.Text, 4))
>
[quoted text clipped - 6 lines]
>
> Francis Brown.

Signature

Dave Peterson

Francis Brown - 22 Jan 2006 15:41 GMT
The text box is always in format xx-xx-xxxx in UK date format. day first.

if the line is swapped for

nYear = CLng(Mid(TextBox3.Text, 7, 4))

then it works.

The left function also works fine.

As I said the function works on my XP system with xl97. when I run it on NT4
at work with xl97 it fails. The code compiles. It is when it is running the
function it fails.

Thanks for input

Francis.
Signature

Regards and Thanks for any assistance.

Francis Brown.

> How does it fail?
>
[quoted text clipped - 28 lines]
> >
> > Francis Brown.
Dave Peterson - 22 Jan 2006 15:58 GMT
I think I'd double check the .text

if isnumeric(right(textbox3.text,4)) then
 nyear = clng(...)
else
 msgbox textbox3.text & " isn't correct"
...

> The text box is always in format xx-xx-xxxx in UK date format. day first.
>
[quoted text clipped - 54 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.