Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Boolean returs Null how to fix?

Status
Not open for further replies.

kalle82

Technical User
Apr 2, 2009
163
SE
I have had this up before but know I kinda know the problem and the question can therefore be direct.

When using this code with the string,

"CARL Kristian Thor" it works and prints CARL
"Patricia Märta Louise" it workand print all of the names
"Patricia" it returns nothing "null"

How can do an else if code so that NULL returns "Patricia"

Code:
Dim strResult
Dim booUpper As Boolean

namnet =  "Patricia"

booUpper = False
For Each strResult In Split(namnet)
If Not (strResult Like "*[a-z]*") Then
   booUpper = True
    Exit For
  End If
Next

[B]' Original code[/b]
If booUpper Then
TextBox18.Value = strResult
Else
TextBox18.Value = namnet
End If
[B]' Newly invented code that does not work[/b]

If booUpper = True Then
TextBox18.Value = strResult
If booupper = false then
TextBox18.Value = namnet
If booupper = Null Then
textBox.value = namnet2

End If
 
Sorry, but you say:
When using this code with the string,"CARL Kristian Thor" it works and prints CARL
"Patricia Märta Louise" it workand print all of the names
"Patricia" it returns nothing "null"
... but for me Patricia returns Patricia with the original code.

Cheers, Glenn.

Beauty is in the eye of the beerholder.
 

At the top of your code use
Code:
Option Explicit
Then try again your original code.

Your Boolean [tt]booUpper[/tt] should never be a NULL

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top