Your SlideShare is downloading. ×
0
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Vb (1)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Vb (1)

1,085

Published on

Published in: Education, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,085
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Working With VB.NET <ul><li>Example For Console Applications </li></ul><ul><li> Module Module1 Sub Main() System.Console.Write(&quot;Welcome to Console Applications&quot;) End Sub End Module </li></ul><ul><li>Note the first line, we're creating a Visual Basic Module and Modules are designed to hold code. All the code which we write should be within the Module. Next line starts with Sub Main(), the entry point of the program. The third line indicates that we are using the Write method of the System.Console class to write to the console. </li></ul>
  • 2. Working With VB.NET <ul><li>Example For Windows Applications </li></ul><ul><li> Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_ Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles Button1.Click </li></ul><ul><li>MsgBox(&quot;Welcome to Forms&quot;) End Sub End Class </li></ul>
  • 3. Variables <ul><li>Variable is a storage area of the computer's memory </li></ul><ul><li>Variables are declared with the Dim keyword. Dim stands for Dimension. In Variables lots of access specifiers are available. </li></ul><ul><li>Access specifiers let's us specify how a variable, method or a class can be used. The following are the most commonly used one's: </li></ul>
  • 4. Variables <ul><li>Public: Gives variable public access which means that there is no restriction on their accessibility </li></ul><ul><li>Private: Gives variable private access which means that they are accessible only within their declaration content </li></ul><ul><li>Protected: Protected access gives a variable accessibility within their own class or a class derived from that class </li></ul><ul><li>Friend: Gives variable friend access which means that they are accessible within the program that contains their declaration </li></ul><ul><li>Protected Friend: Gives a variable both protected and friend access </li></ul><ul><li>Static: Makes a variable static which means that the variable will hold the value even the procedure in which they are declared ends </li></ul><ul><li>Shared: Declares a variable that can be shared across many instances and which is not associated with a specific instance of a class or structure </li></ul><ul><li>ReadOnly: Makes a variable only to be read and cannot be written </li></ul>
  • 5. Variable Examples <ul><li>Imports System .Console Module Module1 Sub Main() Dim a,b,c as Integer 'declaring three variables of type integer a=10 b=20 c=a+b Write(&quot;Sum of a and b is&quot; & c) End Sub End Module </li></ul>
  • 6. Data Types in VB.Net <ul><li>DATATYPE in a programming language describes that what type of data a variable can hold . When we declare a variable, we have to tell the compiler about what type of the data the variable can hold or which data type the variable belongs to. </li></ul>
  • 7. Operators Arithmetic Operators Arithmetic operators are used to perform arithmetic operations that involve calculation of numeric values. The table below summarizes them:
  • 8. Operators Concatenation Operators Concatenation operators join multiple strings into a single string. There are two concatenation operators, + and & as summarized below: Comparison Operators A comparison operator compares operands and returns a logical value based on whether the comparison is true or not. The table below summarizes them:
  • 9. Operators Logical / Bitwise Operators The logical operators compare Boolean expressions and return a Boolean result. In short, logical operators are expressions which return a true or false result over a conditional expression. The table below summarizes them:
  • 10. Examples For Operators <ul><li>Arithmetic Operators </li></ul><ul><li>Imports System.Console Module Module1 Sub Main() Dim x, y, z As Integer x = 30 y = 20 z = x + y WriteLine(&quot;Addition&quot; & &quot; = &quot; & z) z = x - y WriteLine(&quot;Subtraction&quot; & &quot; = &quot; & z) z = x * y WriteLine(&quot;Multiplication&quot; & &quot; = &quot; & z) z = x / y WriteLine(&quot;Division&quot; & &quot; = &quot; & z) Read() End Sub End Module </li></ul><ul><li>. </li></ul>
  • 11. Examples For Operators <ul><li>Concatenation Operators </li></ul><ul><li>Imports System.Console Module Module1 Sub Main() Dim str1, str2, str3, str4 As String str1 = &quot;Concatenation&quot; str2 = &quot;Operators&quot; str3 = str1 + str2 WriteLine(str3) str4 = str1 & str2 WriteLine(str4) Read() End Sub End Module </li></ul>
  • 12. Examples For Operators <ul><li>Concatenation Operators </li></ul><ul><li>Imports System.Console Module Module1 Sub Main() Dim str1, str2, str3, str4 As String str1 = &quot;Concatenation&quot; str2 = &quot;Operators&quot; str3 = str1 + str2 WriteLine(str3) str4 = str1 & str2 WriteLine(str4) Read() End Sub End Module </li></ul>
  • 13. Examples For Operators <ul><li>Comparison Operators </li></ul><ul><li>Imports System.Console Module Module1 Sub Main() Dim x, y As Integer WriteLine(&quot;enter values for x and y &quot;) x = Val(ReadLine()) y = Val(ReadLine()) If x = y Then WriteLine(&quot;x is equal to y&quot;) ElseIf x < y Then WriteLine(&quot;x is less than y&quot;) ElseIf x > y Then WriteLine(&quot;x is greater than y&quot;) End If Read() End Sub End Module </li></ul>
  • 14. Examples For Operators <ul><li>Logical / Bitwise Operators </li></ul><ul><li>Imports System.Console Module Module1 Sub Main() Dim x As Boolean x = Not 45 > 26 WriteLine(&quot;x not is false&quot;) ' x equals false x = Not 26 > 87 ' x equals True WriteLine(&quot;x not is true&quot;) Read() End Sub End Module </li></ul>

×