Page 1 of 2 12 LastLast
Showing results 1 to 20 of 23

Thread: Basic VB Stuff - String Manipulation, Variables, If Statments, For Statments.

  1. #1
    The Sexy Penguin Senior Member
    Retired Staff Member

    Prophet
    LCS's Avatar
    Join Date
    Feb 2005
    Location
    astrotravelin'
    Posts
    7,801

    Default Basic VB Stuff - String Manipulation, Variables, If Statments, For Statments.

    This is a tutorial I wrote a while ago to teach some basic things about VB, this doesn't have any info about hacking but it has some things you can learn from, if you need me to post an example for one of the things in this tutorial just ask.

    Code:
    String Manipulation :
    
    	Val(str1)				Returns the str1 as a value, this is used only for math
    	Len(strSource)				Returns the legnth of a strSource
    	Left$(strSource, #)			Returns the value at # (Starting from left)
    	Right$(strSource, #)			Returns the value at # (starting from right)
    	Mid$(String1, #, #)			Returns the value betweem # and #
    	InStr(#, strSource, strInput)		Starts at # in strSource and looks for strInput
    	Replace(strSource,OldString,NewString)	Replaces an OldString with a NewString, in strSource
    	LCase$(strSource)			Returns strSource in lowercase
    	UCase$(strSource)			Returns strSource in uppercase
    	StrReverse(strSource)			Returns strSource reversed
    	StrCompare(str1, str2)			Compares two strings ASCII values
    	LTrim$(strSource)			Returns strSource with the spaces cut off of the left side of the string
    	RTrim$(strSource)			Returns strSource with the spaces cut off of the right side of the string
    	Trim$(strSource)			Returns strSource with the spaces cut off of the string
    	Split(strSource, Chr(#))		Returns strSource split into an array with the specified character
    	Join(strSource, Chr(#))			Returns strSource with it's array joined with the specified character
    	IsNumeric(strSource)			Returns if strSource is numeric
    	Space$(#)				Returns # of spaces
    
    
    Combining Strings :
    
    	To combine strings you might think you would use "+", you can use "+" to combine strings
    	but the best way to combine strings is by using "&"
    	
    	VbCrLf	-	Makes the text go to a new line..
    	VbTab	-	Adds a tab to the text.
    	Time	-	Returns your computer's time 
    	Date	-	Returns your computer's date
    	
    	Example :
    
    		Public Sub Form_Load()
    			MsgBox "Time " & Time & vbCrLf & "Date " & Date 	
    		End Sub
    
    Option Explicit :
    
    	Option Explicit makes the form your working on check for undeclared variables, and stop 
    	the program an alert you if there is an undeclared variable.
    
    Declaring Variables :
    
    	Dim	-	Declaring a variable.
    	Public	-	Makes the variable useable anywhere in your project.
    	Private	-	Makes the variable useable only on the form you declare it on.
    	Static	-	Remebers the last value assigned to the variable.
    
    Variable Types:
    
    	String	-	stores a string of text.
    	Integer	-	An integer between 32768 and -32768.
    	Byte	-	An integer between 0 and 255.
    	Long	-	An integer extending to billions.
    	Single	-	Stores large numbers.
    	Double	-	Stores large numbers and decimals.
    	Boolean	-	True or False value.
    	Variant -	Any value listed above, memory intensive.
    
    If Statments :
    
    	If		If ... Then (#1, #2, #3)	
    	If Not		If Not ... Then (#5)
    	Or		An Or can be added to the if statement after the first condition as an alternate. (example #7)
    	And		An And can be added to the if statement after the first condition. (example #8)
    	ElseIf		ElseIf ... Then (if you are going to put an elseif in, it always fallows an if statement (example #6))
    	Then		Then always fallows an If, If Not, or an ElseIf (example #1 - 8)
    	Else		Else is the oppisite of If (example #4)
    	End If		End If ends an If statement (unless it is a one line If (example #2)) if there is an ElseIf then put the End If after the ElseIf (example #6) 
    
    Examples :
    
    #1
    	If ... Then
    		...
    	End If
    #2
    	If ... Then ...
    #3
    	If ... Then
    		...
    		...
    		...
    	End If
    #4	
    	If ... Then
    		...
    	Else
    		...
    	End If
    #5
    	If Not ... Then
    		...
    	End If
    #6
    	If ... Then
    		...
    	ElseIf ... Then
    		...
    	End If
    #7
    	If ... Or ... Then
    		...
    	End If
    #8
    	If ... And ... Then
    		...
    	End If
    
    For Statements :
    
    	For (varable)	A For statement starts with For then a variable = #(LBound(...)) to #(UBound(...)) with out setting a Step, a for statement increases by 1. (Example #1-3)
    	Step		A Step can be used to make a For statement that increases by (+,-)# a Step can be used to make a For statement decrease by # or increase #, without setting a Step a For will increase by 1.(Example #2)		
    	Next (varable)	Next (varable) makes the varable increase by the indicated Step or the default 1 and then it will loop back up to the begining of the For statement. (Example #1-3) 
    
    
    Examples :
    
    #1
    	For i = ... to ...
    		...
    	Next i
    #2
    	For i = ... to ... step ...
    		...
    	Next i
    #3
    	for i = LBound(...) to UBound(...)
    		...
    	Next i
    Update by: indulgence [since no one will probably check page 13 or whatever :P]
    Code:
    The If statements area is grossly inadequate...
    If Statments [append] :
    
    	IIf		IIf(Evaluator, ValueIfTrue, ValueIfFalse)
    			' This is comparable to the ? : expressions in C, C++, JS, etc
    			' Example:  
    			' Dim sValue As String = IIf( 0 > 1, "Never gonna return me", "Always will return me")
    	OrElse		If ... OrElse ... Then
    	AndAlso		If ... AndAlso ... Then
    
    The 'With' Statement :
    	The With statement allows you to set a control context for referencing multiple properties more simply...
    	' Example :
    	'    Dim sExample As String = "Jeebus save me"
    	'    Dim iLength, iLength2 As Integer
    	'    With sExample
    	'       iLength = .Length
    	'       iLength2 = .Length
    	'    End With
    	Obviously you can get more complicated than this ;)
    
    Further list that needs commenting on.... but I don't have time to do at the moment.
    - The "For" Statement needs a ForEach description
    - More to come later

  2. #2
    Senior Member

    Saint
    punture's Avatar
    Join Date
    Jul 2004
    Location
    Vancouver, B.C. Canada
    Posts
    6,464

    Default

    nice LCS!

  3. #3
    Arbiter Senior Member
    Retired Staff Member

    Blessed
    TheTempest's Avatar
    Join Date
    Apr 2004
    Posts
    2,086

    Default

    Roar!!! =) Way to go!

    My signature is back!! Hell YES!

    Click the link, I DEMAND YOU! :-D
    http://www.bwhacks.com/forums/showthread.php?t=24873

  4. #4

    Default

    Nice guide. Too bad I already know everything in there, though :]

  5. #5
    =) Senior Member
    Developer

    Supreme Being
    K? Pŕo?ćtiόnŹ's Avatar
    Join Date
    Oct 2004
    Posts
    11,794

    Default

    You decided to post this becuase?
    Quote Originally Posted by Voice Of Korhal View Post
    Let us hope so, if that Reverse Engineering crap actually works, I'll be amazed.

  6. #6
    The Sexy Penguin Senior Member
    Retired Staff Member

    Prophet
    LCS's Avatar
    Join Date
    Feb 2005
    Location
    astrotravelin'
    Posts
    7,801

    Default

    Because it's helpful to newbs.

  7. #7
    The man, myth and legend Retired Staff Member

    Blessed
    c0ke's Avatar
    Join Date
    Jan 1970
    Location
    New Jersey
    Posts
    2,287

    Default

    Either way their home is pscode.com.
    Itís c0ke... itís really me. Disco, if you see this at somepoint, message me!!! Itís been AGES! Anyone else who used to be around in the mid - late 2000s, send a message. I miss you guys, gt and bwh were my teenage years... now that iím basically 30. Time flies people, you wont be young forever!

  8. #8

    Default

    @Coke: LCS got banned from pscode.com. =p(Unless he got unbanned previously? But since you pissed off one of their mods I highly doubt it.)

    @LCS: So, you finally finished up that ole' thing ehh?
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  9. #9
    =) Senior Member
    Developer

    Supreme Being
    K? Pŕo?ćtiόnŹ's Avatar
    Join Date
    Oct 2004
    Posts
    11,794

    Default

    Quote Originally Posted by LCSBSSRHXXX
    Because it's helpful to newbs.
    >_<, not you! To the stupid **** who was trying to show off.
    Quote Originally Posted by Voice Of Korhal View Post
    Let us hope so, if that Reverse Engineering crap actually works, I'll be amazed.

  10. #10
    The Sexy Penguin Senior Member
    Retired Staff Member

    Prophet
    LCS's Avatar
    Join Date
    Feb 2005
    Location
    astrotravelin'
    Posts
    7,801

    Default

    Quote Originally Posted by Uniquely_Defined
    @Coke: LCS got banned from pscode.com. =p(Unless he got unbanned previously? But since you pissed off one of their mods I highly doubt it.)

    @LCS: So, you finally finished up that ole' thing ehh?
    I'm still banned.

  11. #11

    Default

    omg did u block me LCS!?

  12. #12
    The Sexy Penguin Senior Member
    Retired Staff Member

    Prophet
    LCS's Avatar
    Join Date
    Feb 2005
    Location
    astrotravelin'
    Posts
    7,801

    Default

    No, I'm not online, I was making a Top Ramen and I spilled boiling water on my hand an it hurts, also I have to memorize a paper I wrote for German...

  13. #13

    Default

    uh huh whatever....good luck with that:( :(

  14. #14

    Default

    Quote Originally Posted by LCSBSSRHXXX
    I'm still banned.
    Hehe =) That kid was pretty pissed off. :P Well, I should say kids...But that was pretty mean of you too...The funniest part is you did it to yourself!
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  15. #15
    Senior Member

    Crusader
    Dyndrilliac's Avatar
    Join Date
    Jun 2005
    Location
    Jacksonville, FL, USA
    Posts
    3,618

    Default

    Keep in mind that on most of the string manipulation functions (not all) you can trail them with a $. This is not just for the substring functions. The $ tells the compiler they return a string instead of a variant, which makes the program run faster theoretically.
    The Ultimate Guide Thread
    Quote Originally Posted by Ethernet Networking Bible
    Thou shalt switch where thy can, and route where thy must.

  16. #16
    The Sexy Penguin Senior Member
    Retired Staff Member

    Prophet
    LCS's Avatar
    Join Date
    Feb 2005
    Location
    astrotravelin'
    Posts
    7,801

    Default

    I haven't seen you in a while Dyndrilliac where have you been?

  17. #17
    Senior Member

    Crusader
    Dyndrilliac's Avatar
    Join Date
    Jun 2005
    Location
    Jacksonville, FL, USA
    Posts
    3,618

    Default

    I was off in the Bahamas with my wife (honeymoon) having wild sex and getting high. Plus we just moved, and I have to use the computer terminals at the University where I teach until I call my ISP.
    The Ultimate Guide Thread
    Quote Originally Posted by Ethernet Networking Bible
    Thou shalt switch where thy can, and route where thy must.

  18. #18
    The Sexy Penguin Senior Member
    Retired Staff Member

    Prophet
    LCS's Avatar
    Join Date
    Feb 2005
    Location
    astrotravelin'
    Posts
    7,801

    Default

    Ah nice.
    Hehe, just kidding nice to see you back.

  19. #19
    Senior Member

    Crusader
    Dyndrilliac's Avatar
    Join Date
    Jun 2005
    Location
    Jacksonville, FL, USA
    Posts
    3,618

    Default

    I should hope your kidding, if I had taken a camera with me I'd have felt much like the guys on animal planet taking pics of the female lions when their hungry. Oh, and nice to be back :P
    The Ultimate Guide Thread
    Quote Originally Posted by Ethernet Networking Bible
    Thou shalt switch where thy can, and route where thy must.

  20. #20
    Senior Member
    Gold Member

    Inquisitor

    Join Date
    Jan 2005
    Posts
    4,496

    Default

    Yes, indeed. I made a thread specifically asking where you went. I thought you were disturbed by a hurricane, and came out unfortunate. :(

    At any rate, can I ask what you teach now? Thats pretty kool.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •