Mirage Source
String Checks - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+------ Forum: Tutorials (https://mirage-engine.uk/forums/forumdisplay.php?fid=13)
+------ Thread: String Checks (/showthread.php?tid=2679)



String Checks - Jacob - 02-04-2009

This is not my code, i found these examples. I don't remember where though...

Code:
Public Function IsAlpha(s As String) As Boolean
    If Not s Like "*[!A-Za-z]*" Then IsAlpha = True
End Function

Code:
Public Function IsAlphaNumeric(s As String) As Boolean
    If Not s Like "*[!0-9A-Za-z]*" Then IsAlphaNumeric = True
End Function

That's what I use in MR for our legal string checks.


Re: String Checks - William - 02-04-2009

I have never seen that before, care to explain Tongue


Re: String Checks - genusis - 02-04-2009

one only searches the string for capital a-z and lowercase a-z letters.

the other searches for 0-9 cap a-z and lowercase a-z letters based on how you want there names and passwords to be.

Much more accurate than the string check we have now.


Re: String Checks - Dragoons Master - 03-04-2009

WOW!!!
I didn't know VB6 has regular expressions!
That really RLZ!
=D


Re: String Checks - William - 04-04-2009

But I never seen "!" used in a application language :S Dugor, care to explain how it works?


Re: String Checks - Coke - 04-04-2009

Its the 'not' operator, for example...

Code:
Public void Test(int moose){

   If moose != 1337 {
   moose = 1337;
   }

}

Says if the int being passed in isn't set to 1337 then set it to 1337 - see?


Re: String Checks - William - 04-04-2009

Fox Wrote:Its the 'not' operator, for example...

Code:
Public void Test(int moose){

   If moose != 1337 {
   moose = 1337;
   }

}

Says if the int being passed in isn't set to 1337 then set it to 1337 - see?
I understand the code you passed on. But he part:
Code:
!A-Za-z
I can't see how that would work. Why Za for example? I havn't googled this and I'm sure that would give me the info needed. But anyway, I'm to tired to go that way when I'm sure Dugor can explain it with his own words.


Re: String Checks - KruSuPhy - 04-04-2009

Uh.
Za?
Isn't it just "A-Z", Then "a-z" (A-Za-z)


Re: String Checks - William - 04-04-2009

I'm getting too curious about this, the only reason I could think of it being this way is if he declares high characters and low characters. But still that seems odd because you could put a command around it to do that if the if statement wasn't constructed in that way. But I suppose that's the glory about that code. Easier and probably faster.


Re: String Checks - Dragoons Master - 04-04-2009

http://msdn.microsoft.com/en-us/library/swf8kaxw.aspx


Re: String Checks - doomJoost1 - 05-04-2009

Small addon

IF IsNumeric(String) = True Then
Oh, its not true, cause its a string, not a number.
End If

To prevent players sending a string instead of a number which can lead to server crash.