Top Banner

Click here to load reader

of 22

第 3 章 變數、資料 型別與運算子

Jan 01, 2016

Download

Documents

第 3 章 變數、資料 型別與運算子. Ren-Jie Wang, 王 仁 傑 , Ph.D. [email protected] http://rjwang.myweb.hinet.net. 第 3 章 變數、資料 型別與運算子. 3-1 變數與資料 型別的基礎 3-2 變數的命名與宣告 3-3 資料 型別 3-4 運算式與運算子 3-5 資料 型別的轉換. 3-1 變數與資料型別的基礎 - 圖例. 在程式語言的「變數」( Variables )可以視為是一個擁有名稱的盒子,能夠暫時儲存程式執行時所需的資料,如下圖所示:. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 3 Ren-Jie Wang, , Ph.D. [email protected] http://rjwang.myweb.hinet.net

  • 3 3-1 3-2 3-3 3-4 3-5

  • 3-1 -Variables

  • 3-2-1 Visual Basic-Visual Basic(VB)"_"16383abcABC.+-*/^

  • 3-2-1 Visual Basic-Visual Basicdef, no_123, size1, _123, _abc Car, count, height, s1, s2 _ , 123abc

  • 3-2-1 Visual Basic-3

    Boolean

    bln

    blnDoit

    Char

    chr

    chrA

    Integer

    int

    intCounter

    Object

    obj

    objCar

    String

    str

    strName

  • 3-2-1 Visual Basic- CamelCasingCamelCasing1/

    "_"

    MAX_SIZEPI

    22

    sizeuserName

    /

    2

    pressButtonscrollScreen

  • 3-2-2 -Visual BasicDimDim volumnvolumnObjectAsDim height, width As Integer2Dim name As String, depth As Integer

  • 3-2-2 -Dim name As String, depth = 100Dim title As String = "Visual Basic"nametitletitledepth1002008

  • 3-2-6 Enumeration-EnumerationsEnum/End EnumEnum Color As Integer White = 1 Red Blue = 5 Green Black = GreenEnd Enum

  • 3-3

  • 3-3-1 Visual Basic

  • 3-3-2 -

    19

    19

    &O377

    255

    &Hff

    255

    &H3E7

    999

  • 3-3-4 Boolean TypeTrueFalse

  • 3-3-6 Char TypeUnicodeUnsigned16Visual BasicCharacter LiteralsDim a As Char = "A"C

  • 3-3-5 String0String LiteralsDim str1 As String = Visual BasicDim str2 As String = Hello World!Dim str3 As String = _ \\localhost\download\joe

  • 3-3-7 //"#"Dim tday As Date = #12/30/2012 12:00:00 AM#/41224AMPM240

  • 3-4-3 -f = X^2-2*X+3f = (X+Y)^2+5FahrenheitCelsiusF = (9.0 * C) / 5.0 + 32.0C = (5.0 / 9.0 ) * (F - 32)

  • 3-4-4 Like-StringVisual Basic

    &"abc" & "de" = "abcde"LikeTrueFalse

  • 3-4-5 "="

    =

    x = y

    N/A

    ^=

    x ^= y

    x = x ^ y

    +=

    x += y

    x = x + y

    -=

    x -= y

    x = x - y

    *=

    x *= y

    x = x * y

    /=

    x /= y

    x = x / y

    \=

    x \= y

    x = x \ y

    &=

    x &= y

    x = x & y

  • 3-5-1 -Implicit Conversions

    "250" + 125

    375

    "250" & 125

    "250125"

    "250" + "125"

    "250125"