ASP.NET Razor - VB Variables
ကိန်းရှင်များကို ဒေတာသိမ်းဆည်းရန် အသုံးပြုသည့် အရာများဟု အမည်ပေးထားသည်။
ကိန်းရှင်များ
ဒေတာသိမ်းဆည်းရန် ကိန်းရှင်များကို အသုံးပြုသည်။
ကိန်းရှင်တစ်ခု၏အမည်သည် အက္ခရာစာလုံးဖြင့် အစပြုရမည်ဖြစ်ပြီး နေရာလွတ် သို့မဟုတ် သီးသန့်စာလုံးများ မပါဝင်နိုင်ပါ။
ကိန်းရှင်သည် သိမ်းဆည်းထားသည့် ဒေတာအမျိုးအစားကို ညွှန်ပြသော အမျိုးအစားတစ်ခုဖြစ်သည်။ ကြိုးတန်းကိန်းရှင်များသည် string တန်ဖိုးများကို သိမ်းဆည်းသည် ("Welcome to W3Schools")၊ ကိန်းပြည့် variables များ store number values (103)၊ date variables များ store date values စသည်တို့။
variable များအား Dim keyword ကိုအသုံးပြု၍ သို့မဟုတ် အမျိုးအစားကိုအသုံးပြုခြင်းဖြင့် (သင်ကြေငြာလိုပါက၊ type) သို့သော် ASP.NET သည် အများအားဖြင့် ဒေတာအမျိုးအစားများကို အလိုအလျောက် ဆုံးဖြတ်နိုင်သည်။
ဥပမာများ
//
Using the Dim keyword:
Dim greeting = "Welcome to W3Schools"
Dim counter = 103
Dim today = DateTime.Today
// Using data types:
Dim greeting As String = "Welcome to W3Schools"
Dim counter As Integer =
103
Dim today As DateTime = DateTime.Today
ဒေတာအမျိုးအစားများ
အောက်တွင် အသုံးများသော ဒေတာအမျိုးအစားများစာရင်းဖြစ်သည်-
Type | Description | Examples |
---|---|---|
integer | Integer (whole numbers) | 103, 12, 5168 |
double | 64 bit floating-point number | 3.14, 3.4e38 |
decimal | Decimal number (higher precision) | 1037.196543 |
boolean | Boolean | true, false |
string | String | "Hello W3Schools", "John" |
လုပ်ငန်းရှင်များ
အော်ပရေတာတစ်ခုသည် စကားရပ်တစ်ခုတွင် လုပ်ဆောင်ရမည့် command အမျိုးအစားကို ASP.NET အား ပြောပြသည်။
VB ဘာသာစကားသည် အော်ပရေတာများစွာကို ပံ့ပိုးပေးသည်။ အောက်တွင် ဘုံအော်ပရေတာများစာရင်းဖြစ်သည်-
Operator | Description | Example |
---|---|---|
= | Assigns a value to a variable. | i=6 |
+ - * / |
Adds a value or variable. Subtracts a value or variable. Multiplies a value or variable. Divides a value or variable. |
i=5+5 i=5-5 i=5*5 i=5/5 |
+= -= |
Increments a variable. Decrements a variable. |
i += 1 i -= 1 |
= | Equality. Returns true if values are equal. | if i=10 |
<> | Inequality. Returns true if values are not equal. | if <>10 |
< > <= >= |
Less than. Greater than. Less than or equal. Greater than or equal. |
if i<10 if i>10 if i<=10 if i>=10 |
& | Adding strings (concatenation). | "w3" & "schools" |
. | Dot. Separate objects and methods. | DateTime.Hour |
() | Parenthesis. Groups values. | (i+5) |
() | Parenthesis. Passes parameters. | x=Add(i,5) |
() | Parenthesis. Accesses values in arrays or collections. | name(3) |
Not | Not. Reverses true or false. | if Not ready |
And OR |
Logical AND. Logical OR. |
if ready And clear if ready Or clear |
AndAlso orElse |
Extended Logical AND. Extended Logical OR. |
if ready AndAlso clear if ready OrElse clear |
ဒေတာအမျိုးအစားများ ပြောင်းလဲခြင်း။
ဒေတာအမျိုးအစားတစ်ခုမှ အခြားတစ်မျိုးသို့ ပြောင်းလဲခြင်းသည် တစ်ခါတစ်ရံတွင် အသုံးဝင်သည်။
အသုံးအများဆုံးဥပမာမှာ ကိန်းပြည့် သို့မဟုတ် ရက်စွဲကဲ့သို့ string input ကို အခြားအမျိုးအစားသို့ ပြောင်းရန်ဖြစ်သည်။
စည်းကမ်းအတိုင်း၊ အသုံးပြုသူသည် နံပါတ်တစ်ခုထည့်ထားသော်လည်း၊ အသုံးပြုသူထည့်သွင်းမှုသည် စာကြောင်းများအဖြစ်လာသည်။ ထို့ကြောင့်၊ ဂဏန်းထည့်သွင်းမှုတန်ဖိုးများကို တွက်ချက်ရာတွင် အသုံးမပြုမီ ဂဏန်းများအဖြစ်သို့ ပြောင်းရပါမည်။
အောက်တွင် ဘုံပြောင်းလဲခြင်းနည်းလမ်းများ စာရင်းတစ်ခုဖြစ်သည်။
Method | Decryptions | Example |
---|---|---|
AsInt() IsInt() |
Converts a string to an integer. | if myString.IsInt() then myInt=myString.AsInt() end if |
AsFloat() IsFloat() |
Converts a string to a floating-point number. | if myString.IsFloat() then myFloat=myString.AsFloat() end if |
AsDecimal() IsDecimal() |
Converts a string to a decimal number. | if myString.IsDecimal() then myDec=myString.AsDecimal() end if |
AsDateTime() IsDateTime() |
Converts a string to an ASP.NET DateTime type. | myString="10/10/2012" myDate=myString.AsDateTime() |
AsBool() IsBool() |
Converts a string to a Boolean. | myString="True" myBool=myString.AsBool() |
ToString() | Converts any data type to a string. | myInt=1234 myString=myInt.ToString() |