Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 389 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic Statements [VB/C#]

#1
[Image: res0pij.png]
Basic Statements in VB/C#
Written by +.Shebang of +Reverence


Introduction
This is a basic overview of some of the most common (and less common) statements used within VB and C#, which are generally found in most programming languages. Code examples will be provided for both languages so you can learn for either one! There's a table of contents below that should make navigating this thread a little easier. Simply do Ctrl+F, and then the code next to each type of statement. This will allow you to easily jump to the statement you want if you're already familiar with the others.



Table Of Contents
A001: If...Else Statement
A002: Select...Case Statement
A003: Try...Catch...Finally Statement
A004: Using...End Using Statement




A001: If...Else Statement
Basic Layout:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

I'm just going to quickly run through all of the stuff in these statements. Every instance of condition simply shows an area where you are evaluating something, like equal to, less than, or greater than. If is always the first thing that comes in this statement. Else is a generic statement saying that if the first condition is false, the else block will execute. ElseIfs simply provide alternate conditions before it defaults to the else block. AndAlso/&& and OrElse/|| are what to be used when combining conditions. If you want to make sure multiple conditions are met, for example if two boolean values are true, you would use an AndAlso operator. If you only want one condition to be true to execute the block, use an OrElse operator. Using parenthesis in appropriate places can make sure order of operations is followed, so your conditions can be complex, like so:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

As you can see, ElseIfs and Elses are allowed to be omitted. However, you must always open with an If condition. Also, if you are in VB you will notice there are And and Or operators as well, but these are not short-circuiting operators. What that means, is when you use an OrElse, if the first condition is true, it will not bother checking the other statement. However, an Or would check both, and then confirm afterwards whether one of them was true. Same goes with And and AndAlso. And and Or are also used for bitwise operations, so it makes more sense to use OrElse and AndAlso.




A002: Select...Case Statement
Basic Layout:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

As you can see, there are a few differences to the statements between the two languages. Each has support for multiple cases, as well as default cases if no other ones are met. However, the one distinct thing you may notice is that each case I showed is closed with a break operator. In C#, if a break is not specified, the cases following the one met will execute regardless, but in VB, all cases automatically have a break at the end. This is an alternative/shorter solution in some cases where an If statement may be necessary.




A003: Try...End Try Statement
Basic Layout:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

Try statements are used to make sure that your code runs smoothly even when presented with errors, so that they can be properly handled. When an error occurs within a try block, the code will automatically default to a blank catch block (in C#. In VB, this is prevented due to being unsafe). Proper practice is to specify specific exceptions for catch statements that are known to possibly occur, and then to include a default catch, ex As Exception. Afterwards, a Finally block is executed if present, however they can be omitted. Keep in mind that if an error occurs, the rest of the code in the Try block that was never executed will not be, so cleaning up in a Finally statement is a good idea to prevent any issues with your application. The next section talks about a specific application of this concept.




A004: Using...End Using Statement
Basic Layout:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

I will preface this by saying that Using statements are meant solely for objects that implement the IDisposable interface. The Using statement is the simplest way to make sure that objects that use this interface (WebClients and StreamReaders, for example) are disposed of properly. However, these statements do not offer the control of a Try...End Try statement. However, because of how the Using statement works, this will not offer the flexibility of one. Thankfully, the Using statement is simply an adaptation of a Try...End try statement. Below is how the same behaviour can be accomplished with added control:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.





Conclusion
Well, that's everything! Hopefully this gave you enough information to use the statements with some knowledge of what actually goes on with them. If you're new, you can look forward to some tutorials I'll put out on loops and a few other things foun in languages based on the .NET Framework.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through