#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Textboxes

Hi All

I am trying to evaluate two textboxes

If TextBox3.Value TextBox2.Value Then
......
.......
Else
........

End If

but I am getting strange results with the above code
Is their a better solution to this.

Regards

Subs


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Textboxes

It would help to see what the strange results are, but I have an educated
guess. Do the textboxes contain numbers you want to compare? Textbox values
are strings; an alpha comparison on strings gives different results than a
numeric comparison - to see what I mean try this in the immediate pane:
? "10" "2"
Should show the answer is "False" - alphabetically, the "1" in "10" comes
before "2".
Do it this way:
If Val(Textbox3.Value) Val(Textbox2.Value) Then ...
This converts the text to numeric values for the comparison
--
- K Dales


"Subs" wrote:

Hi All

I am trying to evaluate two textboxes

If TextBox3.Value TextBox2.Value Then
......
.......
Else
........

End If

but I am getting strange results with the above code
Is their a better solution to this.

Regards

Subs



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Textboxes

Hi,

In the same way of thinking you can also convert the results to a
certain type and compare then :

If CInt(Textbox3.Value) CInt(Textbox2.Value) Then ...
This converts the text to Integer values for the comparison

Warning : it's also good to check those values BEFORE you make the
comparison.
You can make the check with IsNumeric

Peter

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
Textboxes SAL Excel Discussion (Misc queries) 2 July 13th 07 12:24 AM
tab between several textboxes Kim Excel Worksheet Functions 0 May 9th 05 04:08 PM
sum of textboxes Liedson31 Excel Programming 1 May 3rd 05 06:18 PM
Textboxes Marcotte A Excel Programming 2 July 7th 04 12:55 AM
textboxes libby Excel Programming 5 April 13th 04 06:32 PM


All times are GMT +1. The time now is 11:14 AM.

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

About Us

"It's about Microsoft Excel"