Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > VERY easy question


Reply
 
Thread Tools Display Modes
  #1  
Old 02-28-2005, 01:18 PM
Alphanumeric's Avatar
Alphanumeric Alphanumeric is offline
Junior Contributor
 
Join Date: Mar 2001
Location: Canada
Posts: 388
Default VERY easy question


Hello.

I'm sorry, it's been a while since I've done this, and I can't recall the correct syntax. How do I ignore the case using the Left$() and Right$() statements?

For example........

If Left$(Variable, 1) = "a" Then MsgBox "Hello!"

Variable could possibly be "a" or "A".


Thanks!
__________________
ALPHANUMERIC
Reply With Quote
  #2  
Old 02-28-2005, 01:24 PM
HardCode's Avatar
HardCode HardCode is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Feb 2004
Location: New Jersey
Posts: 3,338
Default

Code:
If LCase(Left$(Variable, 1)) = "a" Then MsgBox "Hello!" If UCase(Left$(Variable, 1)) = "A" Then MsgBox "Hello!"

Alternatively, you can put Option Compare Text at the top of the code sheet, after your Option Explicit.
__________________
DON'T CLICK HERE

Useful forum tags: [VB][/VB], [CODE][/CODE], [HTML][/HTML]
Reply With Quote
  #3  
Old 02-28-2005, 01:24 PM
meteo's Avatar
meteo meteo is offline
Ultimate Contributor
 
Join Date: Aug 2002
Location: Richardson, Texas
Posts: 1,617
Default

UCase and LCase
__________________
WARNING: Self-Taught Programmer. Use at your own risk.
Standards and Practices

Last edited by meteo; 02-28-2005 at 01:24 PM. Reason: Grrrr. HardCode is fast today. = )
Reply With Quote
  #4  
Old 02-28-2005, 01:25 PM
grahamt grahamt is offline
Junior Contributor
 
Join Date: Feb 2005
Posts: 247
Default

You could force it to be upper or lower ...

Code:
If Left$(UCase(Variable), 1) = "A" Then MsgBox "Hello!"

Or see Option Compare Text
Reply With Quote
  #5  
Old 02-28-2005, 01:29 PM
Alphanumeric's Avatar
Alphanumeric Alphanumeric is offline
Junior Contributor
 
Join Date: Mar 2001
Location: Canada
Posts: 388
Default

Haha, I feel so stupid now. I've been using LCase and UCase elsewhere in my program too.

How could I have forgotten? Hah, oh well. Thanks for your help!
__________________
ALPHANUMERIC
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->