مبادئ الـ c# basics
TRANSCRIPT
-
8/3/2019 C# Basics
1/80
Easy Book In FrameWorkPart 1
-
8/3/2019 C# Basics
2/80
1- Console Application
2- 3- 4-
5- StrinBuilder
6-
7- Function 8- Exception 9- InputOutput10-
Environment
11- Structure 12- API Speech
-
8/3/2019 C# Basics
3/80
-:
Console Application
-:
.
:- Console Application
-:
-
8/3/2019 C# Basics
4/80
Ok
>>
-:
Module Module1
Sub Main()
1
1
.
End Sub
End Module
-
8/3/2019 C# Basics
5/80
:-
(
)
:- .
-:
....
Dim M As String
:-
Dim M As Integer
:-
(
)
Dim M As Double
:-
Dim M AS Byte
-
8/3/2019 C# Basics
6/80
-:
Console.Clear() '
Console.Beep() '
Console.BackgroundColor = ConsoleColor.Blue '
Console.Title = ("Meko") '
Console.ForegroundColor = ConsoleColor.DarkGreen '
Console.SetCursorPosition(10, 10) '
Console.Write("Welcome") '
Console.WriteLine("AGC Academy") '
Dim S As String = Console.ReadLine() '
Console .ReadKey() '
-
8/3/2019 C# Basics
7/80
:-
' Dim Name As String = "Malek"Dim Phone As String = "0100309505"
Dim Mail As String = "[email protected]"
'
Console.WriteLine("Name :{0} Phone:{1} Mail:{2}", Name, Phone, Mail)Console.WriteLine("--------------------------------------------------")Console.ReadKey()
----------
-:
'
Console.Write("Enter UR Real Name : ")Dim Rname As String = Console.ReadLine
Console.Write("Enter UR Real Phone : ")Dim RPhone As String = Console.ReadLine
-
8/3/2019 C# Basics
8/80
Console.Write("Enter UR Email : ")Dim Rmail As String = Console.ReadLine
Console.WriteLine("The Information U Entred Is ")
Console.Write("Name: {0} Phone: {1} Mail: {2}", Rname, RPhone, Rmail)
Console.ReadKey()
Enter UR Real Name
Enter UR Real Phone
Enter UR Email
The Information U Entred Is
:-
Boolean
-:
Dim A As Nullable(Of Boolean) = Nothing '
:
-
8/3/2019 C# Basics
9/80
-: Array (Dymention)
:-
'
Dim B(2)B(1) = 200B(2) = 300
Console.WriteLine(B(1))Console.WriteLine(B(2))
Console.ReadKey()
200
300
-:
'
Dim Z(2)Z(1) = 500Z(2) = 600ReDim Z(3)Z(1) = 5Z(2) = 6Z(3) = 7Console.WriteLine(Z(1))Console.WriteLine(Z(2))
-
8/3/2019 C# Basics
10/80
Console.WriteLine(Z(3)Console.ReadKey()
:-
'
Dim Q(2)Q(1) = 100
Q(2) = 200ReDim Preserve Q(4)Q(3) = 300
Q(4) = 400Console.WriteLine(Q(1))Console.WriteLine(Q(2))
Console.WriteLine(Q(3))Console.WriteLine(Q(4))Console.ReadKey()
4 2
-
8/3/2019 C# Basics
11/80
-:
'Console.Write("Enter the Parts of Array : ")
Dim C As Integer = Console.ReadLine
Dim D()ReDim D(C) '
Dim E As Integer = 0
For E = 1 To D.Length - 1
Console.Write("Enter The No. {0} : ", E)D(E) = Console.ReadLine
Next
Console.ReadKey()
Console.WriteLine("The Numbers U entred is ")
Console.WriteLine("------------------------")
Dim F As Integer = 0
For F = 0 To D.Length - 1Console.WriteLine(D(F))
Next
System.Array.Sort(D) '
System.Array.Reverse(D) ' Console.ReadKey()
( )
) )
-: ---------------------
(
)
( )
-
8/3/2019 C# Basics
12/80
:-
'Dim M(2) As String
M(1) = ("Ahmed")M(2) = ("Mohmaed")
System.Array.Sort(M) ' :
Console.Write("Enter The Name U want To Find : ")Dim H As String = Console.ReadLineDim K As Integer = System.Array.BinarySearch(M, H)
Console.WriteLine(K)Console.ReadKey()
( )
()()
(
)
( )
1 Ahmed
-
8/3/2019 C# Basics
13/80
-:
:- { }
-
8/3/2019 C# Basics
14/80
-:
-:
.......
Dim M As String = "Malek"Dim F As String = "Future Developer"Dim L As String = M + F
Console.Write("Enter UR Name : ")Dim R As String = Console.ReadLine
R = LSet(R, 3) '
3
R = RSet(R, 3) '
3
R = M & Space(5) & F '
5
Console.Write(R)
Console.Write(Left(R, 2)) '
Console.WriteLine(Right(R, 2)) '
Console.WriteLine(InStr(R, "M")) ' M
Console.WriteLine(Mid(R, 3, 1)) '
Console.WriteLine(Replace(R, "F", "M")) ' M F
Console.ReadKey()
!!
-:
-
8/3/2019 C# Basics
15/80
-: String Builder
-: String Builder
.String Builder
......
.
-: StringBuilder
:-
'
Dim S As New Text.StringBuilderS.Append("Agc") '
S.AppendLine("Academy") '
S.Remove(5, 3) ' S.Replace("A", "M") ' A M Console.WriteLine(S.ToString) '
Console.ReadKey()
Text.StringBuilder
Agc
Academy
Ag
emy
A
M
-
8/3/2019 C# Basics
16/80
Agc
AcadeAy
( )
-:
:
.
( ) 13.....
255
12245
' Dim A AsInteger = 0For A = 0 To 255Console.WriteLine(Chr(A))
NextConsole.WriteLine("--------")Console.WriteLine(Chr(13))
Console.ReadKey()
-
8/3/2019 C# Basics
17/80
'
Dim SB As New Text.StringBuilder
SB.Append("How R U")Dim E As IntegerFor E = 45 To 122
SB.Replace(Chr(E), Chr(E + 125))
NextConsole.WriteLine(SB.ToString)Console.ReadKey()
Text.StringBuilder
How R U
54
125
125(
)
!! How R U
'
For E = 45 To 122SB.Replace(Chr(E + 125), Chr(E))
NextConsole.WriteLine(SB.ToString)Console.ReadKey()
-
8/3/2019 C# Basics
18/80
How R U
:-
' Dim Sbb As New Text.StringBuilder
Console.Write("Enter The MSg U like To Encrypt : ")Dim G As String = Console.ReadLineSbb.AppendLine(G)
Dim H As Integer = 0For H = 45 To 122
Sbb.Replace(Chr(H), Chr(H + 100) & "@!#")
Next
Console.Write("The Msg After Encrypt : {0}", Sbb.ToString)
Console.ReadKey()
Text.StringBuilder
@!#
How R U
?@!# @!# @!# ?@!# ?@!#!!!!
!!
-
8/3/2019 C# Basics
19/80
'For H = 45 To 122
Sbb.Replace(Chr(H + 100) & "@!#", Chr(H))Next
Console.Write("The Msg After Decrypt : {0}", Sbb.ToString)
Console.ReadKey()
.
How R U
-:
-
8/3/2019 C# Basics
20/80
-:
-:
-:
Project >> Add Reference >> Com >> Microsoft
ActiveX Data Object 2.8 Library
.
-:
UDL
TxT . -:
-
8/3/2019 C# Basics
21/80
-
8/3/2019 C# Basics
22/80
-
8/3/2019 C# Basics
23/80
94
1:
5: (
).
Next 6:
:7
:8
9:
-
8/3/2019 C# Basics
24/80
!! !
Provider
-:
10: 11:
-
8/3/2019 C# Basics
25/80
SQL Serever
Modulemodule1
Dim cn AsNew ADODB.ConnectionDim RS AsNew ADODB.Recordset
Sub main()cn.Open("provider=
sqloledb;database=AGc;Uid=Sa;Pwd=0100309505;server(local)")RS.Open("Student", cn, ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockBatchOptimistic)
EndSub
EndModule
-:
-
8/3/2019 C# Basics
26/80
-:
Funcation -:
:
:-
'
Modulemodule1
Function Avg(ByVal X AsDouble, ByVal Y AsDouble, ByVal Z AsDouble) AsDouble
Return (x + y + z) / 3
EndFunction
Sub main()
Console.WriteLine(Avg(10, 20, 30))Console.ReadKey()
EndSub
EndModule
-
8/3/2019 C# Basics
27/80
Avg
Double
Double X
, Y ,Z
Sub Main
-:
'
Module module1
Function Avg(ByVal x As Double, ByVal y As Double, ByVal z As Double) As Double
Return (x + y + z) / 3
End Function
Sub main()Dim M(3) As Double
Dim H As Double = 0
For H = 1 To M.Length - 1
Console.WriteLine("Enter The three No {0} : ", H)M(H) = Console.ReadLine
Next
Dim L As Double = Avg(M(1), M(2), M(3))Console.WriteLine(L)Console.ReadKey()
End Sub
End Module
-
8/3/2019 C# Basics
28/80
-1 -1
>1>2>3
-1
.. L
( ) L
-
8/3/2019 C# Basics
29/80
:- OverLoad
: OverLoad
OverLoad
2 3
'OverLoad
Module module1
FunctionAvg(ByVal x1 As Double, ByVal x2 As Double, ByVal x3 As Double) As Double
Return (x1 + x2 + x3) / 3End Function
FunctionAvg(ByVal x1 As Double, ByVal x2 As Double) As DoubleReturn (x1 + x2) / 2
End Function
Sub main()
'Console.WriteLine(Avg(10, 2))
Console.ReadKey()
' Console.WriteLine(Avg(10, 20, 30))
Console.ReadKey()End Sub
End Module
AVg 2
2 3
-
8/3/2019 C# Basics
30/80
!!! ByVal Byref
: Byval
: ByRef
' ByVal ByRef
Modulemodule1
PublicSub F(ByRef X AsString)
Dim SB AsNew Text.StringBuilderSB.Append(X)SB.Replace("http:\\", "")
X = SB.ToStringEndSub
Sub main()
Console.Write("Enter URL : ")
Dim N AsStringN = Console.ReadLine
F(N)
Console.WriteLine(N)Console.ReadKey()
EndSub
EndModule
-
8/3/2019 C# Basics
31/80
:-
ByRef
X
F
http://
http://www.AGCACAdemy.com
www.AGCACAdemy.com
ByVal
!!!
http://www.agcacademy.com/http://www.agcacademy.com/http://www.agcacademy.com/http://www.agcacademy.com/ -
8/3/2019 C# Basics
32/80
-: Exception
-:
Err Exception
:-
'
' '
Try
Console.WriteLine("Enter Ur Name : ")Dim M As Integer = Console.ReadLine
Catch ex As Exception
Console.WriteLine("Erorr Because U Dim M as Integer And Enter Name As string PlsRedim M as string ")
'Exception Console.WriteLine("The Error Msg : {0}", ex.Message) '
Console.WriteLine("The Error Number : {0}", Err.Number) ' Console.WriteLine("The Error Line : {0}", Err.Erl) '
'Err Console.WriteLine("The Error Msg : {0}", Err.Description) ' Console.WriteLine("The GetExceptoin : {0}", Err.GetException) '
Console.WriteLine("The HelpContext : {0}", Err.HelpContext) '
Console.WriteLine("The Error source : {0}", Err.Source) ' Console.ReadKey()
End Try
-
8/3/2019 C# Basics
33/80
-: Exception
Try
Catch ex As Exception .... End Try
:- Try
Catch ex As Exception
End Try
-:
'Err
Console.WriteLine("Enter UR Name :")
Dim l As String = Console.ReadLineConsole.ReadKey()Err.Raise(8) ' 8
-
8
!!!
-
8/3/2019 C# Basics
34/80
:-
'
Begin:Console.Write("Enter UR PassWord : ")Dim M AsInteger = Console.ReadLine
Dim C AsIntegerIf C > 3 Then Err.Raise(8)If M "123"Then
Console.WriteLine("invaild Password")C = C + 1
GoTo Begin
EndIfConsole.WriteLine("Welcome U have Enter Right PassWord ")
Console.ReadKey()
.
!!
Bigen
(
)
(
123)
1(
) Begin
......
123
("Welcome U have Enter Right PassWord ")
Begin
-:
-
8/3/2019 C# Basics
35/80
-: Input Output
:-
InputOutput
IO
....
.
...
.
: DirectoryInfo
.....
.
.
: FileInfoDirectoryInfo
.
.
:SreamWriter
StreamReader
: FileStream
...
InputOutput
.
-
8/3/2019 C# Basics
36/80
:-
'InputOutput
Imports System.IO
Modulemodule1
Sub main()
Dim W AsNewDirectoryInfo("C:\\")
Dim D() AsDirectoryInfo = W.GetDirectoriesDim i AsInteger
For i = 1 To D.Length - 1
'C
Console.WriteLine("The Path Files into [C] :{0}", D(i).FullName)
'C Console.WriteLine("The Files Name into [C] :{0}", D(i).Name)
'
Console.WriteLine("The Last Use Time Files into [C] :{0}", D(i).LastAccessTime)
' .. C
Console.WriteLine("The Last Edit Time into Files:{0}", D(i).LastWriteTime)
'Console.WriteLine("The Creation Time Files into [C] :{0}", D(i).CreationTime)
'
Console.WriteLine("-------------------------------------------------")
Next
Console.ReadKey()EndSub
EndModule
Imports System.IO
( )
C:\\ DirectoryInfo
DirectoryInfo C:\\
C:\\
-
8/3/2019 C# Basics
37/80
-:
' Imports System.IO
Modulemodule1
Sub main()
'Dim W AsNewDirectoryInfo("C:\\Malek")If W.Exists = FalseThen '
W.Create() ' ( ) Console.WriteLine("Creation Done ")Console.ReadKey()
Else
' If W.Exists = TrueThen '
W.Delete() ' Console.WriteLine("Deleted Done ")
Console.ReadKey()EndIf
EndIf
EndSub
EndModule
C:\\Malek DirectoryInfo
Malek C
.
-
8/3/2019 C# Basics
38/80
:-
'
Imports System.IO '
-
8/3/2019 C# Basics
39/80
-:
'DirectoryInfo
Imports System.IO
Modulemodule1
Sub main()
Dim W AsNewDirectoryInfo("C:\\Windows")
Dim F() AsFileInfo = W.GetFilesDim I AsInteger
For I = 1 To F.Length - 1Console.WriteLine("The Name :{0}", F(I).Name) ' Console.WriteLine("The Path :{0}", F(I).FullName) ' Console.WriteLine("The Extention :{0}", F(I).Extension) ' Console.WriteLine("The Attributes :{0}", F(I).Attributes) ' Console.WriteLine("----------------------------------------------------")
NextConsole.ReadKey()
EndSubEndModule
C:\Windows DirectoryInfo Windows FileInfo
Windows )-----(
-
8/3/2019 C# Basics
40/80
:-
'
Imports System.IOModulemodule1
Sub main()
'Console.Write("Enter The File Path U like To Encrypt: ")
Dim Path AsString = Console.ReadLine
Dim F AsNewFileInfo(Path)If F.Exists = TrueThen
F.Encrypt() ' Console.WriteLine("Done!")
Console.ReadKey()Else
If F.Exists = FalseThenConsole.WriteLine("The File Not Exists")Console.ReadKey()
EndIf
()
FileInfo
F.Encrypt F.Decrypt()
.....
-
8/3/2019 C# Basics
41/80
'
Console.Write("Enter The File Path U like To Encrypt: ")
Dim Path AsString = Console.ReadLineDim F AsNewFileInfo(Path)
If F.Exists = TrueThen
F.Decrypt() ' Console.WriteLine("Done!")Console.ReadKey()
ElseIf F.Exists = FalseThenConsole.WriteLine("The File Not Exists")Console.ReadKey()
EndIfEndSub
EndModule
:-
'
Imports System.IO
Modulemodule1
Sub main()
Dim WinDire AsNewDirectoryInfo("C:\Windows")
Dim Drs() AsDirectoryInfo = WinDire.GetDirectories
Dim F() AsFileInfo
Dim B AsIntegerDim I AsIntegerOnErrorResumeNext'
For I = 1 To Drs.Length - 1
Console.WriteLine(Drs(I).Name)Console.WriteLine("-----------------------------")F = Drs(I).GetFiles
For B = 1 To F.Length - 1Console.WriteLine(F(B).Name)
NextNextConsole.ReadKey()
EndSubEndModule
-
8/3/2019 C# Basics
42/80
C:\Windows DirectoryInfo
DirectoryInfo
FileInfo
On Error Resume Next
-:
InputOutput
Imports System.IO
:MkDir
:Rename
:RmDir
:Kill
:CurDir
-
8/3/2019 C# Basics
43/80
'
Modulemodule1
Sub main()
MkDir("c:\\Meko") '
Rename("C:\\Meko", "C:\\Malek") ' RmDir("C:\\Malek") ' Kill("c:\\dsn.txt") ' Dim A AsString = CurDir() '
Console.WriteLine(A)Console.ReadKey()
EndSubEndModule
:-
Stream Writer'StreamWriter
Imports System.IO
Modulemodule1
Sub main()Dim Sw AsStreamWriter = File.AppendText("C:\\Agc.txt") '
Console.WriteLine("Enter UR Name: ")Dim M AsString = Console.ReadLine
Sw.WriteLine(M) ' Sw.WriteLine("---------")Sw.Close() '
EndSub
EndModule
IO
Imports System.IO
StreamWriter
Dim Sw AsStreamWriter
-
8/3/2019 C# Basics
44/80
C:\\Agc.txt
(
)
Dim Sw AsNewStreamWriter("C:\\Agc.txt", True)
StreamWriter True
(
)
Dim Sw AsNewStreamWriter("C:\\Agc.txt", False)StreamWriter
False
Console.WriteLine("Enter UR Name: ")
Dim M AsString = Console.ReadLineSW
M
)----(
Sw.WriteLine(M)Sw.WriteLine("---------")
Sw
Sw.Close
Sw.Flush()
...
-
8/3/2019 C# Basics
45/80
:-
Stream Reader
'StreamReader
Imports System.IO
ModuleModule1
Sub MAIN()
Dim Sr AsStreamReader = File.OpenText("C:\\Agc.txt") ' Dim H AsString = Sr.ReadLine ' Console.WriteLine(H)
Console.ReadKey()
EndSub
EndModule
StreamReader
( ) Dim Sr AsStreamReader = File.OpenText("C:\\Agc.txt")
Dim Sr AsNewStreamReader("C:\\sgc.txt")
Dim H AsString = Sr.ReadLine
ReadLine
.......
-
8/3/2019 C# Basics
46/80
Dim C AsStringDoWhileNot Sr.EndOfStream
C = Sr.ReadLineConsole.WriteLine(C)
Loop
Dim H AsString = Sr.ReadToEnd
ReadToEnd
Dim B AsString = Sr.Read
Read
( )
-
8/3/2019 C# Basics
47/80
:- File Stream
:-
(1)
....
!!!
.....
-
8/3/2019 C# Basics
48/80
'FileStream
Imports System.IO
ModuleModule1
Sub main()Dim FS AsNewFileStream("c:\\Malek.jpg", FileMode.Open)Dim H(2) AsByteDim F(2) AsByte
FS.Read(H, 0, 2)FS.Seek(-2, SeekOrigin.End)FS.Read(F, 0, 2)
FS.Seek(-2, SeekOrigin.End)FS.Write(H, 0, 2)
FS.Seek(0, SeekOrigin.Begin)FS.Write(F, 0, 2)
FS.Close()
Console.WriteLine("Done")Console.ReadKey()
EndSub
EndModule
FileStream
C:\\Malek.jpg
( )
Dim FS AsNewFileStream("c:\\Malek.jpg", FileMode.Open)
)
)
.
H
FS.Read(H, 0, 2)
FS.Seek(-2, SeekOrigin.End)
F
FS.Read(F, 0, 2)
!!!!! 2
H
2 F
(
.(
-
8/3/2019 C# Basics
49/80
.....!!!!
H FS.Seek(-2, SeekOrigin.End)
FS.Write(H, 0, 2)
F
FS.Seek(0, SeekOrigin.Begin)
FS.Write(F, 0, 2)FS.Close()
Console.WriteLine("Done")
-
8/3/2019 C# Basics
50/80
!!! :
2
2
!!
:
....
-
8/3/2019 C# Basics
51/80
:-
...
'
Imports System.IOModuleModule1
Function Encryption(ByVal Fn AsString, ByVal L AsInteger) AsString
If L > 20 ThenReturn"Choose Another No"
EndIf
IfFile.Exists(Fn) = FalseThen
Return"File Not Found"EndIf
Dim fS AsNewFileStream(Fn, FileMode.Open)Dim H(L) AsByteDim F(L) AsByte
fS.Read(H, 0, L)fS.Seek(-L, SeekOrigin.End)fS.Read(F, 0, L)
fS.Seek(-L, SeekOrigin.End)fS.Write(H, 0, L)
fS.Seek(0, SeekOrigin.Begin)fS.Write(F, 0, L)fS.Close()Return"Done"
Console.ReadKey()
EndFunction
Sub main()
Console.WriteLine("Enter File Path")Dim A AsString = Console.ReadLine
Console.WriteLine("Enter Encryption No")Dim B AsInteger = Console.ReadLine
Dim S AsString = Encryption(A, B)Console.WriteLine(S)Console.ReadKey()
EndSub
EndModule
-
8/3/2019 C# Basics
52/80
2
Fn AsString
L AsInteger
. Function Encryption(ByVal Fn AsString, ByVal L AsInteger) As
String
20 L
If L > 20 ThenReturn"Choose Another No"
.
Fn 20
EndIf
IfFile.Exists(Fn) = FalseThenReturn"File Not Found"
L
EndIfDim fS AsNewFileStream(Fn, FileMode.Open)
Dim H(L) AsByteDim F(L) AsByte
fS.Read(H, 0, L)fS.Seek(-L, SeekOrigin.End)
fS.Read(F, 0, L)fS.Seek(-L, SeekOrigin.End)
fS.Write(H, 0, L)fS.Seek(0, SeekOrigin.Begin)
fS.Write(F, 0, L)
fS.Close()Return"Done"
Console.ReadKey()!!!
L 2
-
8/3/2019 C# Basics
53/80
:-
Environment
-:
...
.... Cmd
(Cmd)
C:\Windows\System32
Start >> Run >> Cmd
-
8/3/2019 C# Basics
54/80
:-
..... CommandLine
'
Dim X AsString = Environment.CommandLineIf InStr(X, "Agc") > 0 Then
Console.WriteLine("Welcome to Agc Academy")Console.ReadKey()
EndEndIfErr.Raise(9)
(Environment.CommandLine)
Agc
Agc
9
!!
:
EXE :
Relase
Build >> Build Project
Relase
-
8/3/2019 C# Basics
55/80
EXE
-
8/3/2019 C# Basics
56/80
Bin Bin >> Relase >>
!! !
Agc
-:
Agc
-
8/3/2019 C# Basics
57/80
:
:
Project Agc
Welcom to Agc Academy
-
8/3/2019 C# Basics
58/80
-:
: CurrentDirectory
'
'
Dim M AsString = Environment.CurrentDirectoryConsole.WriteLine(M)
'C
Environment.CurrentDirectory = "C:\\"Dim x AsString = Environment.CurrentDirectory
Console.WriteLine(x)Console.WriteLine("The Project File Moved Done")Console.ReadKey()
Environment.CurrentDirectory C
-
8/3/2019 C# Basics
59/80
:-
'
Dim A AsString = Environment.MachineName ' Console.WriteLine(A)Console.WriteLine("=======================")
Dim B AsInteger = Environment.ProcessorCount '
Console.WriteLine(B)Console.WriteLine("=======================")
Dim C = Environment.Version ' (Console.WriteLine(C Console.WriteLine("=======================")
Dim D = Environment.UserName ' Console.WriteLine(D)Console.WriteLine("=======================")
Dim E AsString = Environment.HasShutdownStarted '
Console.WriteLine(E)Console.WriteLine("=======================")
Dim G = Environment.CurrentDirectory '
Console.WriteLine(G)Console.WriteLine("=======================")
Dim H = Environment.WorkingSet '
Console.WriteLine(H)Console.WriteLine("=======================")
Console.ReadKey()
!!
-
8/3/2019 C# Basics
60/80
:- Structure
:
.
-
:-
Modulemodule1
StructureDetailsDim UserName AsStringDim Password AsString
Dim Address AsStringEndStructure
Sub main()
Dim D AsDetails
Console.Write("Enter UserName:")D.UserName = Console.ReadLine()
Console.Write("Enter Password: ")
D.Password = Console.ReadLine
Console.Write("Enter UR Address: ")D.Address = Console.ReadLine
Console.WriteLine(D.UserName)Console.WriteLine(D.Password)
Console.WriteLine(D.Address)Console.ReadKey()
EndSubEndModule
-
8/3/2019 C# Basics
61/80
Details
Dim D AsDetails
( )
-:
....
' Modulemodule1
StructureStudent
Dim RealName AsStringDim Math AsDoubleDim Physics AsDouble
Dim Chemestry AsDouble
Dim Piolgy AsDoubleDim Total AsDouble
Dim Percent AsDouble
EndStructure
Sub main()
Dim S AsStudentConsole.Write("Enter Ur Real Name : ")
S.RealName = Console.ReadLine
Console.Write("Enter Ur Math Degree : ")S.Math = Console.ReadLine
Console.Write("Enter Ur Physics : ")S.Physics = Console.ReadLine
Console.Write("Enter Ur Chmestry Degree : ")S.Chemestry = Console.ReadLine
-
8/3/2019 C# Basics
62/80
Console.Write("Enter Ur Piolgy Degree : ")S.Piolgy = Console.ReadLine
Dim T AsDoubleT = S.Math + S.Physics + S.Chemestry + S.Piolgy
S.Total = TConsole.WriteLine("UR Total Degree : {0}", T)
S.Percent = (T * 100) / 200Console.WriteLine("Ur Percent Degree : {0}%", S.Percent)
Console.ReadKey()EndSub
EndModule
Student
6
Dim S AsStudent
Math , Physics , Chmestry , Piolgy
50 *50=2004
200
100
S.Percent = (T * 100) / 200
100 200
....
-
8/3/2019 C# Basics
63/80
:-
'
Modulemodule1
StructureStudent
Dim RealName AsStringDim Math AsDoubleDim Physics AsDouble
Dim Chemestry AsDoubleDim Piolgy AsDouble
Function T() AsDouble
T = Math + Physics + Chemestry + PiolgyEndFunctionFunction P() AsDouble
P = (T() * 100) / 200
EndFunction
Function Rating() AsStringIf P() < 50 Then Rating = "Drop"
If P() >= 50 And P() < 60 Then Rating = "Passed"If P() >= 60 And P() < 80 Then Rating = "Good"If P() > 70 And P() > 80 Then Rating = "V.Good"
If P() > 90 Then Rating = "Excellent"
EndFunction
EndStructure
Sub main()
Dim S AsStudentConsole.Write("Enter Ur Real Name : ")
S.RealName = Console.ReadLine
Console.Write("Enter Ur Math Degree : ")
S.Math = Console.ReadLine
Console.Write("Enter Ur Physics : ")
S.Physics = Console.ReadLine
Console.Write("Enter Ur Chmestry Degree : ")
S.Chemestry = Console.ReadLine
-
8/3/2019 C# Basics
64/80
Console.Write("Enter Ur Piolgy Degree : ")S.Piolgy = Console.ReadLine
Console.WriteLine("UR Total Degree : {0}", S.T)Console.WriteLine("Ur Percent Degree : {0}%", S.P)Console.WriteLine("Ur Rating: {0}", S.Rating)
Console.ReadKey()EndSub
EndModule
...
...
Student
4
Dim RealName AsString
Dim Math AsDoubleDim Physics AsDouble
Dim Chemestry AsDouble
Dim Piolgy AsDouble
:
:
Function T() AsDouble
T = Math + Physics + Chemestry + PiolgyEndFunction
-
8/3/2019 C# Basics
65/80
:
Function P() AsDoubleP = (T() * 100) / 200
EndFunction
( )100
200
:
Function Rating() AsStringIf P() < 50 Then Rating = "Drop"
If P() >= 50 And P() < 60 Then Rating = "Passed"If P() >= 60 And P() < 80 Then Rating = "Good"
If P() > 70 And P() > 80 Then Rating = "V.Good"If P() > 90 Then Rating = "Excellent"
EndFunction
(
) 50%
(
) 50%
(
) 60%
(
) 70%
(
) 90%
-
8/3/2019 C# Basics
66/80
-:
'
Modulemodule1
StructureStudent
Dim RealName AsString
Dim Math AsDoubleDim Physics AsDoubleDim Chemestry AsDouble
Dim Piolgy AsDouble
Function T() AsDoubleT = Math + Physics + Chemestry + Piolgy
EndFunction
Function P() AsDouble
P = (T() * 100) / 200EndFunction
Function Rating() AsStringIf P() < 50 Then Rating = "Drop"If P() >= 50 And P() < 60 Then Rating = "Passed"
If P() >= 60 And P() < 80 Then Rating = "Good"If P() > 70 And P() > 80 Then Rating = "V.Good"If P() > 90 Then Rating = "Excellent"
EndFunction
Sub Display()
Console.WriteLine("-----------------------------------")Console.WriteLine("RealName: {0}", RealName)Console.WriteLine("Math: {0}", Math)
Console.WriteLine("chmestry: {0}", Chemestry)Console.WriteLine("physics: {0}", Physics)Console.WriteLine("piolgy: {0}", Piolgy)
Console.WriteLine("Total Degree: {0}", T)Console.WriteLine("Percent: {0}%", P)Console.WriteLine("Rating: {0}", Rating)
Console.WriteLine("-----------------------------------")
EndSub
EndStructure
-
8/3/2019 C# Basics
67/80
Sub main()
Dim S AsStudent
S.RealName = "Meko"
S.Math = 20S.Physics = 12
S.Chemestry = 15S.Piolgy = 20S.Display()
Console.ReadKey()EndSub
EndModule
...
.
Student
( )
( )
( )
Sub Display()
(-----)
Console.WriteLine("-----------------------")Console.WriteLine("RealName: {0}", RealName)
Console.WriteLine("Math: {0}", Math)Console.WriteLine("chmestry: {0}", Chemestry)
Console.WriteLine("physics: {0}", Physics)
Console.WriteLine("piolgy: {0}", Piolgy)Console.WriteLine("Total Degree: {0}", T)
-
8/3/2019 C# Basics
68/80
Console.WriteLine("Percent: {0}%", P)
Console.WriteLine("Rating: {0}", Rating)Console.WriteLine("--------------------")
EndStructure
Dim S AsStudentS.RealName = "Meko"
S.Math = 20S.Physics = 12
S.Chemestry = 15
S.Piolgy = 20S.Display()
Display
!!
...
-
8/3/2019 C# Basics
69/80
:-
-:
AGC
Student
....
' Modulemodule1
'
Dim Cn AsNew ADODB.Connection
Dim Rs AsNew ADODB.Recordset
'StructureStudent
'Dim RealName AsStringDim Math AsDoubleDim Physics AsDouble
Dim Chemestry AsDoubleDim Piolgy AsDouble
-
8/3/2019 C# Basics
70/80
' Function T() AsDouble
T = Math + Physics + Chemestry + PiolgyEndFunction
' Function P() AsDouble
P = (T() * 100) / 200
EndFunction
'Function Rating() AsString
If P() < 50 Then Rating = "Drop"If P() >= 50 And P() < 60 Then Rating = "Passed"If P() >= 60 And P() < 80 Then Rating = "Good"
If P() > 70 And P() > 80 Then Rating = "V.Good"If P() > 90 Then Rating = "Excellent"
EndFunction
'
Sub Display()
Console.WriteLine("-----------------------------------")Console.WriteLine("RealName: {0}", RealName)Console.WriteLine("Math: {0}", Math)
Console.WriteLine("chmestry: {0}", Chemestry)Console.WriteLine("physics: {0}", Physics)Console.WriteLine("piolgy: {0}", Piolgy)
Console.WriteLine("Total Degree: {0}", T)Console.WriteLine("Percent: {0}%", P)Console.WriteLine("Rating: {0}", Rating)
Console.WriteLine("-----------------------------------")EndSub
'Sub Find(ByVal Rname AsString)
Cn.Open("provider= SQLOLEDB;Initial
Catalog=AGC;UID=Sa;Pwd=0124330708;Server=(Local)")Rs.Open("Student", Cn, ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockBatchOptimistic)
Rs.Find("RealName='" & Rname & " '")If Rs.EOF Or Rs.BOF Then
Console.WriteLine("Name Not Found")Exit Sub
EndIf
RealName = Rs("RealName").ValueMath = Rs("Math").Value
Physics = Rs("physics").ValueChemestry = Rs("chemistry").ValuePiolgy = Rs("piolgy").ValueDisplay()
Rs.Close()Cn.Close()
EndSubEndStructure
-
8/3/2019 C# Basics
71/80
Sub main()
Dim S AsStudentConsole.Write("Enter UR Name : ")
Dim A AsString = Console.ReadLineS.Find(A)
Console.ReadKey()
EndSubEndModule
.
(
(
( )
( )
( )
( )
Sub Find(ByVal Rname AsString)
( )
( )
ByVal Rname AsString
Console.WriteLine("Name Not Found")
Display
-
8/3/2019 C# Basics
72/80
!!
....
Find
!!! (
)
-
Find - Rs.Close
Cn.Close
.
-
8/3/2019 C# Basics
73/80
:-
API Speech
:-
. API Speech
.....
...
:-
' ModuleModule1
Sub Main()
Dim Sp AsObjectSp = CreateObject("SApI.Spvoice")Sp.Speak("I Love You AGC")
EndSub
EndModule
SApI.Spvoice
Sp = CreateObject("SApI.Spvoice")
SP
Sp.Speak("I Love You AGC")
....
-
8/3/2019 C# Basics
74/80
-:
'
ModuleModule1
Sub main()Dim Sp AsObject
Sp = CreateObject("SApI.Spvoice")Console.Write("Enter The Words U Like To Speech: ")Dim A AsString = Console.ReadLine
Sp.Speak(A)EndSub
EndModule
SApI.Spvoice
Sp = CreateObject("SApI.Spvoice")
SP
Console.Write("Enter The Words U Like To Speech: ")
Sp
Dim A AsString = Console.ReadLine
Sp.Speak(A)
-
8/3/2019 C# Basics
75/80
:-
DLL
Dll
. ClassLibrary
:
: :
: Ok))
-
8/3/2019 C# Basics
76/80
Public Class Class1
Class1
'
PublicClassSpeekVoice
Sub Speak(ByVal Msg AsString)
Dim Sp AsObjectSp = CreateObject("SApI.Spvoice")Sp.Speak(Msg)
EndSub
EndClass
SpeekVoice Speak
Msg
-
8/3/2019 C# Basics
77/80
...
Relase
Build >> Build Class Library1
Relase Bin
...
Project>> AddRefrence >> Browse >>
-
8/3/2019 C# Basics
78/80
....Sub Main()
Dim M AsNew ClassLibrary1.SpeekVoice
Console.Write("Enter Your Words ")Dim N AsString = Console.ReadLineM.Speak(N)
EndSub
M Dim M AsNew ClassLibrary1.SpeekVoice
ClassLibrary1
SpeekVoice
Console.Write("Enter Your Words ")
Dim N AsString = Console.ReadLine
-
8/3/2019 C# Basics
79/80
Speak
Msg
-
8/3/2019 C# Basics
80/80
Easy Book In FrameWork
-:
:
-:
:
...
mailto:[email protected]:[email protected]