www.Hacking-Romania.com
Hacking, gaby hacker team, programe hack, radmin hack, hi5 hack, hack the west, hacking romania, hacking stuff, hacking tools, 1 hack, 1st hacks, 2 hack, 2 hacks, 3 hack, 3 hacks, 3000 hack, 3004 hack, 4 hack, 4 hacks, 55 hack, 6 hack, 6 hacks, 7 hack, 7 hacks, 9 hack, 9dragons hack, a hack, adventure quest hack, aim hack, alz hack, and hacks, best hack, blue hack, bots hack, bots hacks, buy hack, cabal online hack, chaos hacks, cheat engine hack, cheat hack, cheats and hacks, cheats hacks, city hack, club hack, combo hack, conquer hacks, conquer online hack, conquer online hacks, conquer speed hack, conquiztador hack, counter strike 1.6 hack, damage hack, de hack, download hack, download hack for, dragonfable hack, dragonfable hacks, drakkarious hack, exp hack, flyff hack, free hack, free hacks, game hack, game hacks, garena exp hack, gladiatus hack, gm hack, gold hack, gunz hack, hack, hack 5, hack a pc, hack a site, hack a website, hack blog, hack conquer, hack counter strike, hack crack, hack cs, hack cs 1.6, hack dvd, hack email, hack forum, hack hunter, hack id, hack info, hack it, hack mess, hack muonline, hack net, hack password, hack passwords, hack pc, hack pdf, hack programs, hack site, hack sites, hack soft, hack software, hack team, hack the game, hack this, hack website, hack windows xp, hack world, hack xp, hacked, hacking, hacking game, hacking programs, hacking software, hacking tutorials, hacks, how hack, how to hack, icon hack, last chaos hack, last chaos hacks, life hack, lineage 2 hack, lineage 2 hacks, linux hack, lvl hack, maplestory hacks, mobile hack, multi hack 3.0, mybrute hack, naruto arena hack, naruto arena hacks, one hit kill hack, online hacks, perfect world hacks, pool hack, programe hack, resolution hack, resource hack, roll hack, royal hack, silkroad hack, source hack, speed hack, speed hacks, super hack, the west hack, warrock hack, warrock hacks, web hack, xpango hack, lockerz forum
Lista Forumurilor Pe Tematici
www.Hacking-Romania.com | Reguli | Inregistrare | Login

POZE WWW.HACKING-ROMANIA.COM

Nu sunteti logat.
Nou pe simpatie:
georgyana92
Femeie
19 ani
Galati
cauta Barbat
29 - 62 ani
www.Hacking-Romania.com / Hacking T00ls / Conditional Statements in Visual Basic  
Autor
Mesaj Pagini: 1
jocker
HACKING~TEAM

Inregistrat: acum 16 ani
Postari: 910
This chapter describes:
Code:



"If" Statements
"If" Statement Example
"Select Case" Statements
"Select Case" Statement Example




"If" Statements
There 4 flavors of "If" statements in VB:
1. Single-statement "If":
If condition Then statement
where "condition" is Boolean value, and "statement" is any VB statement. The specified statement will be executed, if and only if the specified condition is "True".
2. Multi-statement "If":
If condition Then
statement_block (multiple statements)
End If
The specified multi-statement block will be executed, if and only if the specified condition is "True".
3. "If ... Else" Statement:
If condition Then
statement_block_a
Else
statement_block_b
End If
Two statement blocks are specified. But only one statement block will be executed based on the value of the specified condition. If the specified condition is "True", the first block will be executed. If the specified condition is "False", the second block will be executed.
4. "If ... ElseIf" Statement:
If condition_1 Then
statement_block_1
ElseIf condition_2 Then
statement_block_2
...
...
Else
statement_block_n
End If
Many statement blocks are specified. But only one statement block will be executed based on the value of the condition specified for that block.
"If" Statement Example
To help you understand how "If" statements work, I wrote the following the example, condition_if.html:



<html>
<body>
<!-- condition_if.html
Copyright (c) 2006 by Dr. Herong Yang.
-->
<pre>
<script language="vbscript">
' Single-statement "If"
bIsNewYear = True
document.writeln(""
If bIsNewYear Then document.writeln("Happy New Year!"
' Multi-statement "If"
bIsLogOn = True
document.writeln(""
If bIsLogOn Then
document.writeln("Open the log file."
document.writeln("Write the log message."
document.writeln("Close the log file."
End If

' "If ... Else" statement
bIsAdmin = False
document.writeln(""
If bIsAdmin Then
document.writeln("Display the delete button."
document.writeln("Display the edit button."
Else
document.writeln("Display the view button."
End If

' "If ... ElseIf" statement
iDay = 4
If iDay = 0 Then
sOpenHours = "closed"
ElseIf iDay >= 1 And iDay <=5 Then
sOpenHours = "open from 9:00am to 9:00pm"
ElseIf iDay = 6 Then
sOpenHours = "open from 9:00am to 5:00pm"
Else
sOpenHours = "undefined"
End If
document.writeln(""
document.writeln("The library is " & sOpenHours)
</script>
</pre>
</body>
</html>


Here is the output:
Happy New Year!
Open the log file.
Write the log message.
Close the log file.
Display the view button.
The library is open from 9:00am to 9:00pm
The output matches my expectation perfectly!
"Select Case" Statements
"Select Case" statement is an alternative way of executing statements selectively based on certain conditions. Here is the syntax of "Select Case" statements:
Select Case test_value
Case expected_value_list_1
statement_block_1
Case expected_value_list_2
statement_block_2
...
...
Case Else
statement_block_n
End Select
where "test_value" is a value used to test against with expected values specified in the "Case" clauses, and "expected_value_list_*" are lists of expected values. The execution of "Select Case" statement goes like this:
Each "Case" clause will be visited sequentially from top to bottom.
If one of the values in the expected value list equals to the test value in a "Case" clause, the statement block in that clause will be executed.
If the statement block of any "Case" clause gets executed, the entire statement ends.
The "Case Else" clause is a special clause. Its statement block will be executed if and only if no statement block of any other "Case" clauses gets executed.
"Select Case" Statement Example
To help you understand how "Select Case" statements work, I wrote the following the example, condition_case.html:
Code:


<html>
<body>
<!-- condition_case.html
Copyright (c) 2006 by Dr. Herong Yang.
-->
<pre>
<script language="vbscript">
iDay = 4
Select Case iDay
Case 0
sDay = "Sunday"
sOpenHours = "closed"
Case 1, 2, 3, 4, 5
sDay = "a weekday"
sOpenHours = "open from 9:00am to 9:00pm"
Case 6
sDay = "Saturday"
sOpenHours = "open from 9:00am to 5:00pm"
Case Else
sDay = "unkown"
sOpenHours = "undefined"
End Select
document.writeln(""
document.writeln("Today is " & sDay)
document.writeln("The library is " & sOpenHours)
</script>
</pre>
</body>
</html>


Here is the output:
Today is a weekday
The library is open from 9:00am to 9:00pm
Hope you know how to use "Select Case" statements now.
Conclusions
Remember that:
"If" must be followed by a condition and "Then".
"ElseIf" is one word, no space.
"Case" is followed by a list of expected values.
Unlike C language, no need to break statements in "Case" clauses.

statements visual basic this chapter statements statement example case" statements case"

4.8KB


_______________________________________
[img]http://i320.photobucket.com/albums/nn324/pad_vlad/moderator-3.gif[/img]

pus acum 16 ani
   
Pagini: 1  

Mergi la