

![]() |
![]() |
|
|||||||
![]() |
![]() |
| Programming General non-hacking related programming. |
![]() |
|
|
LinkBack | Thread Tools |
![]() |
![]() |
|
|
#1 (permalink) | ||
|
The Sexy Penguin
Senior Member
Retired Staff Member ![]() ![]() ![]() Prophet |
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 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
__________________
Quote:
LCS, 707, BELPHEGOR YEEEEEEEH BITCH Quote:
|
||
|
|
|
![]() |
![]() |
|
Advertisement
|
|
![]() |
![]() |
|
|
#3 (permalink) |
|
Arbiter
Senior Member
Retired Staff Member ![]() ![]() ![]() Blessed Join Date: Apr 2004
Posts: 2,092
![]() ![]() ![]() |
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 |
|
|
|
![]() |
![]() |
![]() |
![]() |
|
|
#6 (permalink) | ||
|
The Sexy Penguin
Senior Member
Retired Staff Member ![]() ![]() ![]() Prophet |
Because it's helpful to newbs.
__________________
Quote:
LCS, 707, BELPHEGOR YEEEEEEEH BITCH Quote:
|
||
|
|
|
![]() |
![]() |
![]() |
![]() |
|
|
#7 (permalink) |
|
What ever it takes!
Retired Staff Member
![]() ![]() ![]() Blessed |
Either way their home is pscode.com.
__________________
Because she's hot.Proud member of the Fair Lawn Fire Department.Badge: A-1 “I have no ambition in this world but one, and that is to be a fireman. The position may, in the eyes of some, appear to be a lowly one; but we who know the work which the fireman has to do believe that his is a noble calling. Our proudest moment is to save lives. Under the impulse of such thoughts, the nobility of the occupation thrills us and stimulates us to deeds of daring, even of supreme sacrifice.” " And let no man say, My training let me down." -- Edward F. Croker Chief of Department
F.D.N.Y. 1899-1911 |
|
|
|
![]() |
![]() |
![]() |
![]() |
|
|
#8 (permalink) |
|
Senior Member
![]() ![]() ![]() ![]() ![]() Crusader |
@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 |
|
|
|
![]() |
![]() |
![]() |
![]() |
|
|
#10 (permalink) | |||
|
The Sexy Penguin
Senior Member
Retired Staff Member ![]() ![]() ![]() Prophet |
Quote:
![]()
__________________
Quote:
LCS, 707, BELPHEGOR YEEEEEEEH BITCH Quote:
|
|||
|
|
|
![]() |
![]() |
![]() |
![]() |
|
|
#12 (permalink) | ||
|
The Sexy Penguin
Senior Member
Retired Staff Member ![]() ![]() ![]() Prophet |
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...
__________________
Quote:
LCS, 707, BELPHEGOR YEEEEEEEH BITCH Quote:
|
||
|
|
|
![]() |
![]() |