Presentation is loading. Please wait.

Presentation is loading. Please wait.

סוגי מידע / משתנים ד " ר אבי רוזנפלד. סוגאורךטווח Boolean1 Bit0,1 Byte1 byte0-255 Char 2 bytes תו Decimal16 bytes0 through +/-79,228,162,514,264,337,593,543,950,335.

Similar presentations


Presentation on theme: "סוגי מידע / משתנים ד " ר אבי רוזנפלד. סוגאורךטווח Boolean1 Bit0,1 Byte1 byte0-255 Char 2 bytes תו Decimal16 bytes0 through +/-79,228,162,514,264,337,593,543,950,335."— Presentation transcript:

1 סוגי מידע / משתנים ד " ר אבי רוזנפלד

2 סוגאורךטווח Boolean1 Bit0,1 Byte1 byte0-255 Char 2 bytes תו Decimal16 bytes0 through +/-79,228,162,514,264,337,593,543,950,335 Single4 bytes401298E-45 through 3.4028235E+38 Double8 bytes4.94065645841246544E-324 through 1.79769313486231570E+308 Integer4 bytes-2,147,483,648 through 2,147,483,647 Long8 bytes-9,223,372,036,854,775,808 through 9,223,372,036,854,775,807 Short2 bytes-32,768 through 32,767 StringVariable מילה

3 דוגמה פשוטה Module Module1 Sub Main() Dim x As Integer x = 10 Console.WriteLine((x + 2) / 10) Console.ReadKey() End Sub End Module

4 מה זה יעשה ? Module Module1 Sub Main() Dim x As Integer x = 10 Console.WriteLine(x + 2 * 10 + 1) Console.ReadKey() End Sub End Module

5 מה יהיה הפלט ? Module Module1 Sub Main() Dim x, y, z As Integer x = 10 y = x / 3 z = x / 4 Console.WriteLine("x is " & x) Console.WriteLine("y is " & y) Console.WriteLine("z is " & z) Console.ReadKey() End Sub End Module

6 מבוא לתכנות למע " ס - מאיר קומר - סמסטר הצבה (השמה) - assignment Dim count as integer =1 num 5 num = 5 num = num + count 6 count Dim num as integer 1

7 מבוא לתכנות למע " ס - מאיר קומר - סמסטר אופרטורים -+*/-+*/ Mod \

8 מבוא לתכנות למנע " ס - שבוע מספר 2 - מאיר קומר - סמסטר ב ' - תשס " ו Const pi As single = 3.1415 יש גם קבועים

9 סוגים שונים של מידע (long) Module Module1 Sub Main() Dim x, y, z As Long x = 10 y = x / 3 z = x / 4 Console.WriteLine("x is " & x) Console.WriteLine("y is " & y) Console.WriteLine("z is " & z) Console.ReadKey() End Sub End Module

10 סוגים שונים של מידע (short) Module Module1 Sub Main() Dim x, y, z As Short x = 10 y = x / 3 z = x / 4 Console.WriteLine("x is " & x) Console.WriteLine("y is " & y) Console.WriteLine("z is " & z) Console.ReadKey() End Sub End Module

11 סוגים שונים של מידע (String) Module Module1 Sub Main() Dim x, y, z As String x = "Hello World" 'y = x / 3 This is in a comment 'z = x / 4 This is too Console.WriteLine("x is " & x) Console.WriteLine("y is " & y) Console.WriteLine("z is " & z) Console.ReadKey() End Sub End Module

12 מה זה יעשה ? Module Module1 Sub Main() Dim x, y, z As String x = "Hello World" y = x + " Aviland " z = x + " what???? " + y 'This actually works! Console.WriteLine("x is " & x) Console.WriteLine("y is " & y) Console.WriteLine("z is " & z) Console.ReadKey() End Sub End Module

13 העולם של קלט אתה חייב משתנה ( זיכרון לאחסן את המידע ) אתה גם חייב משתנה מתאים של Console.ReadLine

14 דוגמא Module Module1 Sub Main() Dim x, y As String x = "Hello World" Console.WriteLine(x) y = Console.ReadLine() 'It waits until "enter" Console.WriteLine("You typed " & y) Console.ReadKey() End Sub End Module

15 זה לא יעבוד Module Module1 Sub Main() Dim x As Integer x = Console.Read() ' this reads as a word! 'It waits until "enter" Console.WriteLine("You typed " & x + 1) Console.ReadKey() End Sub End Module

16 זה כן יעבוד Module Module1 Sub Main() Dim x As Integer x = Console.ReadLine() 'this works! 'It waits until "enter" Console.WriteLine("You typed " & x + 1) Console.ReadKey() End Sub End Module

17 מה זה יעשה ? Module Module1 Sub Main() Dim x As Integer Dim y As Decimal y = Console.ReadLine 'It waits until "enter" x = y Console.WriteLine("The whole portion was " & x) Console.WriteLine("The input was " & y) Console.WriteLine("The decimal was " & y - x) Console.ReadKey() End Sub End Module

18 Type Casting (and fun!) Module Module1 Sub Main() Dim thousands, hundreds, tens, ones As Integer Dim whole, stam_unused_variable As Decimal Console.WriteLine("Please enter a number greater than 1000 ") whole = Console.ReadLine 'It waits until "enter" thousands = Int(whole / 1000) whole -= thousands * 1000 hundreds = Int(whole / 100) whole -= hundreds * 100 tens = Int(whole / 10) ones = whole Mod 10 'Just for show off mod Console.WriteLine("The thousands part is " & thousands & ", the hundreds part is " & hundreds) Console.WriteLine("The tens portion is " & tens & " and the ones portion is " & ones) Console.ReadKey() End Sub End Module

19 פלט לקבצים Imports System.IO 'Notice the import! Module Module1 Sub Main() Dim writer As StreamWriter = _ New StreamWriter("z:\KBTest.txt") writer.WriteLine("File created using StreamWriter class2.") writer.Write("What???") writer.Close() End Sub End Module

20 דוגמא לקלט Imports System.IO 'Notice the import! Module Module1 Sub Main() Dim fileReader As StreamReader fileReader = _ My.Computer.FileSystem.OpenTextFileReader("KBTest.txt") Dim x As String x = fileReader.ReadLine() Console.WriteLine("The file line of the file is " & x) Console.ReadKey() End Sub End Module


Download ppt "סוגי מידע / משתנים ד " ר אבי רוזנפלד. סוגאורךטווח Boolean1 Bit0,1 Byte1 byte0-255 Char 2 bytes תו Decimal16 bytes0 through +/-79,228,162,514,264,337,593,543,950,335."

Similar presentations


Ads by Google