Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Right text function

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.
--
Regards and Thanks for any assistance.

Francis Brown.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Right text function

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???



Francis Brown wrote:

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.
--
Regards and Thanks for any assistance.

Francis Brown.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Right text function

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.
--
Regards and Thanks for any assistance.

Francis Brown.


"Dave Peterson" wrote:

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???



Francis Brown wrote:

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.
--
Regards and Thanks for any assistance.

Francis Brown.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Right text function

I think I'd double check the .text

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

Francis Brown wrote:

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.
--
Regards and Thanks for any assistance.

Francis Brown.

"Dave Peterson" wrote:

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???



Francis Brown wrote:

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.
--
Regards and Thanks for any assistance.

Francis Brown.


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
using a conditional suffix in text function format syntax=text(value,format_text) Brotherharry Excel Worksheet Functions 1 January 13th 09 03:03 PM
Can Text Function change output text color? epiekarc Excel Discussion (Misc queries) 1 December 31st 08 02:58 AM
Advanced text function (combining text) Johan[_2_] Excel Worksheet Functions 2 March 27th 08 10:05 PM
Using Concatenate function to generate text in Text Box Mary S. Charts and Charting in Excel 1 December 14th 05 08:55 PM
Macro or Function to make text size to suite text Length? lbbss Excel Discussion (Misc queries) 4 December 14th 04 07:53 PM


All times are GMT +1. The time now is 09:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"