SlideShare a Scribd company logo
1 of 5
Download to read offline
Norton University Lesson 1 Subject ៖ VB.NET 
Academic year: 2014-2015 Page 1 Lecturer: Msc OU Bundeth 
មេម ៀនទី ១៖ កា ចាប់មផតើេជាេួយ VS, Variable, Data Type 
1. Visual Studio 
យយើងដឹងយ ើយថា Microsoft Visual Studio 2012 គឹជា IDE ថ្មីមួយដដលយគយររើសរារ់យ្វើជាកដលលងសរយសរលូវ កូដ C#, VB.NET, ASP.NET លិង Windows Phone Application ដូយ្នេះយយើងររូវដឹងពីការ្ំណុ្មួយ្ំលួលខាងយរកាម ៖ 
យលេះជា Interface ររស់ Microsoft Visual Studio 2012 រូររាងររស់វាហាក់ដូ្ជាាលរាងដរលក លិង រសស់ ស្អារ ។ 
- យដើមបីយ្វើការរយងកើរលូវ Project ថ្មីសរារ់យ្វើការសរយសរអ្នកររូវ្ូលយៅកនុង File Menu រន្ទារ់មកយក New Project (Ctrl+N) រួ្វាលឹង pop up ផ្ាំងដូ្ខាងយរកាមសរារ់យ្វើការយររើសយរើសយកដាក់យ្មេះ Project លិង យររើសយរើស .NET Framework សរារ់យ្វើការសរយសរយៅយលើ Library យន្ទេះ ។ កនុងយន្ទេះដដរអ្នកអា្យ្វើការសរយសរយៅយលើកមមវិ្ីមួយ ្ំលួលដូ្ជា ៖ Windows Application, Web Application(ASP.NET for VB.NET/C#), Windows Mobile Application, Console Application លិង កមមវិ្ីមួយ្ំលួលយ ៀរ ។
Norton University Lesson 1 Subject ៖ VB.NET 
Academic year: 2014-2015 Page 2 Lecturer: Msc OU Bundeth 
 VB.NET Interface 
ខាងយរកាមយលេះជា Project ដដលយយើងបាលរយងកើរដដលាលយ្មេះថា demo យ ើយយៅយពលដដលយយើងរយងកើរ Project យលេះ យយើងលឹងបាល Form មួយយ្មេះថា Form 1 ។ 
យលេះជា Tool មួយ្ំលួលសរារ់យររើយៅកនុង VS ដូ្ជា Toolbox, Properties, Event លិងSolution Explorer ។
Norton University Lesson 1 Subject ៖ VB.NET 
Academic year: 2014-2015 Page 3 Lecturer: Msc OU Bundeth 
- Solution Explorer (Ctrl+Alt+L) គឹជាកដលលងសរារ់ផ្ាុករាល់ Form លិងClass ទំងអ្ស់យៅកនុង Project ទំងមូល លិង Properties ររស់ Project ផ្ងដដរ ។ 
- Toolbox (Ctrl+Alt+X)ជាកដលលងសរារ់ផ្ាុកលូវ Control ដដលលឹងយកមិលយររើយៅកនុង Visual Studio យលេះ យ ើយ Control យលេះបាលដរងដ្កយ្ញជា Container ររស់វាជាយរស្ដដលាលលកខណៈងាយរសួលកនុងដសវងរកយកមកយររើ ។ 
- Properties (F4) ជាកដលលងសរារ់កំណរ់លកខណៈយៅឱ្យ Form ឬ Control ណាមួយ ដូ្ជា ៖ យ្មេះ ំ ំអ្កសរ ជាយដើម ។ 
- Event ជាកដលលងសរារ់ផ្ាុកលូវរាល់ Event ទំងអ្ស់ររស់ Control ណាមួយ ។ 
្ំណាំ ៖ 
- ្ំយ េះការដំយណើរការ Project យលេះយយើងអា្្ុ្ F5 (ដំយណើរយដាយាលការ Check មកកាល់ Program វិញ ) 
- Ctrl+F5 ( ដំយណើរការយដាយមិល Debug មកកាល់ Program វិញយ ដរវាយ្វើការ Alert ជា Message លូវការ Error យន្ទេះ ) ។ 
 VB.NET Coding 
ការសរយសរកូដនលភាស្អ VB.NET ររូវបាលដរងដ្កជាដូ្ខាងយរកាម ៖ 
- Namespace ជាកដលលងយៅលូវ Library dll file នល Project ឬ Class ណាមួយមកយររើយៅកនុង Form។ 
- Class Form ជាកូដសរារ់ដំយណើរការ លូវ Event ររស់ Form ឬ អា្សរយសរជា Function ឬ Class ដន យ ៀរ ។ 
- Form Design កដលលងសរារ់សរយសរកូដរងាាញ Control ណាមួយយៅកនុង Form ជា ូយៅ File យលេះររូវបាល Hide ។ 
្ំណាំ ៖ Short Cut យៅកនុងការសរយសរកូដ 
- F7 សរារ់រតូរយៅ ការសរយសរកូដ 
- Shift+ F7 សរារ់រតូរយៅ Design 
2. Variable 
Variable គឺជាអ្យថ្រមួយដដលាលន្ទ ីយ្វើការ Store data ជារយណាតេះអាសលនយពលដដល Program កំពុងដំយណើរការ យ ើយរំនលដដលវារកា ុកយន្ទេះគឺ String, Datetime, Number, Boolean លិង Object ។ 
2.1 រយរៀរររកាស Vairable 
Syntax1: Public/Private/Dim VariableName As DataType 
EX: - DimLastName As String=”Sok” 
- Dim LastName As String 
LastName=”Sok” 
- Dim LastName.FirstName As String 
- Dim LastName As String,FirstName As String 
Syntax2: Static VariableName As DataType 
សរារ់រយងកើរលូវ Variable ដដលាលរនមលអា្យររើបាលយៅ Form ឬ Class ដ៏ន យ ៀរយដាយមិលចំបា្់រយងកើរ Object នល Class យន្ទេះ ។ 
Syntax3: Const VariableName As DataType 
សរារ់រយងកើរ Variable ដដលាលរនមលយថ្រ ឬ មិលដររររួល លិងមិលអា្ Assign រនមលបាល ។ 
Syntax4: Dim VariableName 
សរារ់រយងកើរលូវ Dynamic Data Type ដររររួលយៅតាមរនមលដដលយយើងបាល Assign ឱ្យ ។ 
ការរយងកើរ Variable យយើងររូវយោរពតាមយោលការណ៍ដូ្ខាងយរកាម ៖ 
- ររូវដរចរ់យផ្តើមយដាយអ្កសរ 
- មិលអា្ាល Space យរើដកឃ្លលររូវយររើ 
- Underscore( _ ) 
- ររូវាលដរមួយគរ់យៅកនុងដដលកំណរ់ 
- ររូវដរាលល័យយៅលឹងអ្វីដដលយយើង្ង់យររើ 
- ររូវកំណរ់ Data type យអាយបាល្ាស់លាស់យៅយពលដដលចរ់យផ្តើមរយងកើរ ។
Norton University Lesson 1 Subject ៖ VB.NET 
Academic year: 2014-2015 Page 4 Lecturer: Msc OU Bundeth 
2.2 Type Conversion 
យៅកនុងការ Convert Data type មួយយៅ Data Type មួយយយើងអា្ Convert បាលតាម ៣ រយរៀរ ៖ 
a. Convert.to 
Ex: Convert.toint32() 
Convert.todbl() 
Convert.todatetime() 
b. Datatype.parse 
Ex: Integer.parse 
Doble.parse 
Boolean.parse 
c. CDatatype 
Ex: Clng 
Cint 
Cdbl 
*** Format: 
- number: 
Ex: Format(num, "0.##") 
FormatCurrency(num, 2) 
- Datetime: 
FormatDateTime(Today.Now, DateFormat) 
+ DateFormat.GeneralDate 
+ DateFormat.LongDate 
+ DateFormat.LongTime 
+ DateFormat.ShortDate 
+ DateFormat.ShortTime 
3. Data Type 
- Boolean: True/false Default value: False 
- Number 
+ Integer: 
Sbyte : (-127 to 128) 1 byte 
Byte : (0 to 255) 1 byte 
Short : (-32 768 to 32 767) 2 bytes 
Ushort : (0 to 65 535) 2 bytes 
Integer: (-231 to 231-1) 4 bytes 
Uinteger: (0 to 232-1) 4 bytes 
Long: (-263 to 263-1) 8 bytes 
Ulong: (0 to 264) 8 bytes 
+ Float: 
Single: (1.5 x 10-45 to 3.4 x 1038) 4 bytes 
Double: (5.0 x 10-324 to 1.7 x 10308) 8 bytes 
Decimal : ( 1.0 x 10-28 to 7.9 x 1028) 16bytes
Norton University Lesson 1 Subject ៖ VB.NET 
Academic year: 2014-2015 Page 5 Lecturer: Msc OU Bundeth 
- Date: 1-Jan-0001 to 31-Dec-9999 Default value: 1-Jan-0001 
- String Array of char up to 2G Default value: “” 
- Object Support all data type Default value: nothing 
4. Operator 
Operators គឺជា Symbol ដដល Operate យៅយលើ Operand យដើមបីរយងកើរល ធផ្លអ្វីមួយ។ 
1.4.1 Arithmetic Operators 
Arithmetic Operators ររូវបាលយររើយៅកនុង Mathematical Expression ។ Operand ររស់ Arithmetic Operators ររូវាលររយេ ជា Number ។ 
Operator Operator Name 
+ Addition 
- Substraction 
* Multiplication 
/ Division 
 Integer Division 
Mod Modulation 
^ Exponentiation 
1.4.2 Comparison Operators 
Comparison Operators ាលន្ទ ីសំរារ់កំណរ់ ំន្ទក់ ំលងរវាង Operand ពីរថាយរើវាយសមើោន ឬ ខុសោន ឬ រូ្ជាង ឬ ្ំជាង ។ 
Operator Operator Name 
= Equal to 
<> Not Equal to 
> Greater than 
>= Greater than or equal to 
< Less than 
<= Less than or equal to 
Like Matches a text pattern (Similarity) 
1.4.3 Boolean logical Operator or Conditional Operator 
យយើងយររើ Conditional Operators យដើមបីយររៀយ្ៀរ រវាង Operand ពីរ ឬ យរ្ើល ។ 
Operator Meaning 
And វា return true យពលដដលលកខខណឌទំងពីរពិរ ។ 
Or វា return true យពលដដលលកខខណឌទំងពីរមួយណាពិរ ។ 
Not វា return true យពលដដលលកខខណឌមិលពិរ ។ 
Xor វា return true យពលដដលលកខខណឌទំងពីរមួយណាពិរដរមិលពិរទំងពីរ។ 
1.4.4 Assignment operator 
យយើងយររើ Operators យលេះយដើមបី យកខលួលទងយៅ យ្វើការជាមួយ operators យផ្សងយ ៀរ ។ 
Operator Example 
+= i+=1 => i=i+1 
-= i-=1 => i=i-1 
*= i*=1 => i=i*1 
/= i/=1 => i=i/1 
= i=1 => i=i1 
&= i&=1 => i=i&1

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

មេរៀនទី ១៖ ការចាប់ផ្តើមជាមួយ Vs, variable, data type

  • 1. Norton University Lesson 1 Subject ៖ VB.NET Academic year: 2014-2015 Page 1 Lecturer: Msc OU Bundeth មេម ៀនទី ១៖ កា ចាប់មផតើេជាេួយ VS, Variable, Data Type 1. Visual Studio យយើងដឹងយ ើយថា Microsoft Visual Studio 2012 គឹជា IDE ថ្មីមួយដដលយគយររើសរារ់យ្វើជាកដលលងសរយសរលូវ កូដ C#, VB.NET, ASP.NET លិង Windows Phone Application ដូយ្នេះយយើងររូវដឹងពីការ្ំណុ្មួយ្ំលួលខាងយរកាម ៖ យលេះជា Interface ររស់ Microsoft Visual Studio 2012 រូររាងររស់វាហាក់ដូ្ជាាលរាងដរលក លិង រសស់ ស្អារ ។ - យដើមបីយ្វើការរយងកើរលូវ Project ថ្មីសរារ់យ្វើការសរយសរអ្នកររូវ្ូលយៅកនុង File Menu រន្ទារ់មកយក New Project (Ctrl+N) រួ្វាលឹង pop up ផ្ាំងដូ្ខាងយរកាមសរារ់យ្វើការយររើសយរើសយកដាក់យ្មេះ Project លិង យររើសយរើស .NET Framework សរារ់យ្វើការសរយសរយៅយលើ Library យន្ទេះ ។ កនុងយន្ទេះដដរអ្នកអា្យ្វើការសរយសរយៅយលើកមមវិ្ីមួយ ្ំលួលដូ្ជា ៖ Windows Application, Web Application(ASP.NET for VB.NET/C#), Windows Mobile Application, Console Application លិង កមមវិ្ីមួយ្ំលួលយ ៀរ ។
  • 2. Norton University Lesson 1 Subject ៖ VB.NET Academic year: 2014-2015 Page 2 Lecturer: Msc OU Bundeth  VB.NET Interface ខាងយរកាមយលេះជា Project ដដលយយើងបាលរយងកើរដដលាលយ្មេះថា demo យ ើយយៅយពលដដលយយើងរយងកើរ Project យលេះ យយើងលឹងបាល Form មួយយ្មេះថា Form 1 ។ យលេះជា Tool មួយ្ំលួលសរារ់យររើយៅកនុង VS ដូ្ជា Toolbox, Properties, Event លិងSolution Explorer ។
  • 3. Norton University Lesson 1 Subject ៖ VB.NET Academic year: 2014-2015 Page 3 Lecturer: Msc OU Bundeth - Solution Explorer (Ctrl+Alt+L) គឹជាកដលលងសរារ់ផ្ាុករាល់ Form លិងClass ទំងអ្ស់យៅកនុង Project ទំងមូល លិង Properties ររស់ Project ផ្ងដដរ ។ - Toolbox (Ctrl+Alt+X)ជាកដលលងសរារ់ផ្ាុកលូវ Control ដដលលឹងយកមិលយររើយៅកនុង Visual Studio យលេះ យ ើយ Control យលេះបាលដរងដ្កយ្ញជា Container ររស់វាជាយរស្ដដលាលលកខណៈងាយរសួលកនុងដសវងរកយកមកយររើ ។ - Properties (F4) ជាកដលលងសរារ់កំណរ់លកខណៈយៅឱ្យ Form ឬ Control ណាមួយ ដូ្ជា ៖ យ្មេះ ំ ំអ្កសរ ជាយដើម ។ - Event ជាកដលលងសរារ់ផ្ាុកលូវរាល់ Event ទំងអ្ស់ររស់ Control ណាមួយ ។ ្ំណាំ ៖ - ្ំយ េះការដំយណើរការ Project យលេះយយើងអា្្ុ្ F5 (ដំយណើរយដាយាលការ Check មកកាល់ Program វិញ ) - Ctrl+F5 ( ដំយណើរការយដាយមិល Debug មកកាល់ Program វិញយ ដរវាយ្វើការ Alert ជា Message លូវការ Error យន្ទេះ ) ។  VB.NET Coding ការសរយសរកូដនលភាស្អ VB.NET ររូវបាលដរងដ្កជាដូ្ខាងយរកាម ៖ - Namespace ជាកដលលងយៅលូវ Library dll file នល Project ឬ Class ណាមួយមកយររើយៅកនុង Form។ - Class Form ជាកូដសរារ់ដំយណើរការ លូវ Event ររស់ Form ឬ អា្សរយសរជា Function ឬ Class ដន យ ៀរ ។ - Form Design កដលលងសរារ់សរយសរកូដរងាាញ Control ណាមួយយៅកនុង Form ជា ូយៅ File យលេះររូវបាល Hide ។ ្ំណាំ ៖ Short Cut យៅកនុងការសរយសរកូដ - F7 សរារ់រតូរយៅ ការសរយសរកូដ - Shift+ F7 សរារ់រតូរយៅ Design 2. Variable Variable គឺជាអ្យថ្រមួយដដលាលន្ទ ីយ្វើការ Store data ជារយណាតេះអាសលនយពលដដល Program កំពុងដំយណើរការ យ ើយរំនលដដលវារកា ុកយន្ទេះគឺ String, Datetime, Number, Boolean លិង Object ។ 2.1 រយរៀរររកាស Vairable Syntax1: Public/Private/Dim VariableName As DataType EX: - DimLastName As String=”Sok” - Dim LastName As String LastName=”Sok” - Dim LastName.FirstName As String - Dim LastName As String,FirstName As String Syntax2: Static VariableName As DataType សរារ់រយងកើរលូវ Variable ដដលាលរនមលអា្យររើបាលយៅ Form ឬ Class ដ៏ន យ ៀរយដាយមិលចំបា្់រយងកើរ Object នល Class យន្ទេះ ។ Syntax3: Const VariableName As DataType សរារ់រយងកើរ Variable ដដលាលរនមលយថ្រ ឬ មិលដររររួល លិងមិលអា្ Assign រនមលបាល ។ Syntax4: Dim VariableName សរារ់រយងកើរលូវ Dynamic Data Type ដររររួលយៅតាមរនមលដដលយយើងបាល Assign ឱ្យ ។ ការរយងកើរ Variable យយើងររូវយោរពតាមយោលការណ៍ដូ្ខាងយរកាម ៖ - ររូវដរចរ់យផ្តើមយដាយអ្កសរ - មិលអា្ាល Space យរើដកឃ្លលររូវយររើ - Underscore( _ ) - ររូវាលដរមួយគរ់យៅកនុងដដលកំណរ់ - ររូវដរាលល័យយៅលឹងអ្វីដដលយយើង្ង់យររើ - ររូវកំណរ់ Data type យអាយបាល្ាស់លាស់យៅយពលដដលចរ់យផ្តើមរយងកើរ ។
  • 4. Norton University Lesson 1 Subject ៖ VB.NET Academic year: 2014-2015 Page 4 Lecturer: Msc OU Bundeth 2.2 Type Conversion យៅកនុងការ Convert Data type មួយយៅ Data Type មួយយយើងអា្ Convert បាលតាម ៣ រយរៀរ ៖ a. Convert.to Ex: Convert.toint32() Convert.todbl() Convert.todatetime() b. Datatype.parse Ex: Integer.parse Doble.parse Boolean.parse c. CDatatype Ex: Clng Cint Cdbl *** Format: - number: Ex: Format(num, "0.##") FormatCurrency(num, 2) - Datetime: FormatDateTime(Today.Now, DateFormat) + DateFormat.GeneralDate + DateFormat.LongDate + DateFormat.LongTime + DateFormat.ShortDate + DateFormat.ShortTime 3. Data Type - Boolean: True/false Default value: False - Number + Integer: Sbyte : (-127 to 128) 1 byte Byte : (0 to 255) 1 byte Short : (-32 768 to 32 767) 2 bytes Ushort : (0 to 65 535) 2 bytes Integer: (-231 to 231-1) 4 bytes Uinteger: (0 to 232-1) 4 bytes Long: (-263 to 263-1) 8 bytes Ulong: (0 to 264) 8 bytes + Float: Single: (1.5 x 10-45 to 3.4 x 1038) 4 bytes Double: (5.0 x 10-324 to 1.7 x 10308) 8 bytes Decimal : ( 1.0 x 10-28 to 7.9 x 1028) 16bytes
  • 5. Norton University Lesson 1 Subject ៖ VB.NET Academic year: 2014-2015 Page 5 Lecturer: Msc OU Bundeth - Date: 1-Jan-0001 to 31-Dec-9999 Default value: 1-Jan-0001 - String Array of char up to 2G Default value: “” - Object Support all data type Default value: nothing 4. Operator Operators គឺជា Symbol ដដល Operate យៅយលើ Operand យដើមបីរយងកើរល ធផ្លអ្វីមួយ។ 1.4.1 Arithmetic Operators Arithmetic Operators ររូវបាលយររើយៅកនុង Mathematical Expression ។ Operand ររស់ Arithmetic Operators ររូវាលររយេ ជា Number ។ Operator Operator Name + Addition - Substraction * Multiplication / Division Integer Division Mod Modulation ^ Exponentiation 1.4.2 Comparison Operators Comparison Operators ាលន្ទ ីសំរារ់កំណរ់ ំន្ទក់ ំលងរវាង Operand ពីរថាយរើវាយសមើោន ឬ ខុសោន ឬ រូ្ជាង ឬ ្ំជាង ។ Operator Operator Name = Equal to <> Not Equal to > Greater than >= Greater than or equal to < Less than <= Less than or equal to Like Matches a text pattern (Similarity) 1.4.3 Boolean logical Operator or Conditional Operator យយើងយររើ Conditional Operators យដើមបីយររៀយ្ៀរ រវាង Operand ពីរ ឬ យរ្ើល ។ Operator Meaning And វា return true យពលដដលលកខខណឌទំងពីរពិរ ។ Or វា return true យពលដដលលកខខណឌទំងពីរមួយណាពិរ ។ Not វា return true យពលដដលលកខខណឌមិលពិរ ។ Xor វា return true យពលដដលលកខខណឌទំងពីរមួយណាពិរដរមិលពិរទំងពីរ។ 1.4.4 Assignment operator យយើងយររើ Operators យលេះយដើមបី យកខលួលទងយៅ យ្វើការជាមួយ operators យផ្សងយ ៀរ ។ Operator Example += i+=1 => i=i+1 -= i-=1 => i=i-1 *= i*=1 => i=i*1 /= i/=1 => i=i/1 = i=1 => i=i1 &= i&=1 => i=i&1