|
-
Oct 2nd, 2000, 02:28 PM
#1
Thread Starter
New Member
Hello,I am new to vb and I had this question.
I need to read a file that has different fields.
one of the fields has to be uppercase.
what i need to do is a validation if the string is lowercase raise an error.
It only has to be upper.
Thanx for your help
-
Oct 2nd, 2000, 02:32 PM
#2
Fanatic Member
This will check for uppercase:
Code:
Dim SomeText As String
SomeText = "HELLO"
If Ucase(SomeText) = SomeText Then
Msgbox "Uppercase."
Else
MsgBox "Not uppercase."
End If
-
Oct 2nd, 2000, 02:34 PM
#3
Frenzied Member
There is a like function (forgot my vb textbook at school so I can't show you how to use it) sorry
-
Oct 2nd, 2000, 04:13 PM
#4
Like is a simple operator.
Code:
If String1 Like String2 Then TheyAreTheSame
-
Oct 2nd, 2000, 04:57 PM
#5
_______
<?>
Private Sub Command1_Click()
'this will not work as ucase converts it to uppercase
'and so it will always be uppercase even if it isn't
Dim SomeText As String
SomeText = "Hello"
If UCase(SomeText) = SomeText Then
MsgBox "Uppercase."
Else
MsgBox "Not uppercase."
End If
End Sub
'option like is not an option as you are not
'comparing strings you are merely looking for
'any uppercase characters anywhere in string
'Working Code
Code:
Option Explicit
Private Sub Form_Load()
'this would be the var read from file
Dim myString As String
myString = "hello"
Dim myLen As Integer 'string len
Dim iCount As Integer 'var to loop the string
'set to false at beginning
myAt = False
'get the len for loop
myLen = Len(x)
'loop and check for ascii value of letters in string
For iCount = 1 To myLen
y = Left(x, 1)
'if any capital found then alert user and exit sub
If Asc(y) <= 90 _
And Asc(y) >= 65 Then
MsgBox "Capital is included"
Exit Sub
End If
Next
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|