Wednesday, September 20, 2017

ການນຳໃຊ້ Arrays (VB6 Lesson 13)

ດ້ວຍການກຳນົດ ແລ້ວ Array ເປັນຕົວປ່ຽນໜື່ງ ທີ່ມີຊື່ດຽວ ແຕ່ມັນສະແດງເຖິງຫລາຍຄ່າທີ່ຕ່າງກັນ ເມື່ອເຮົາທຳງານກັບ ໜື່ງລາຍການ ເຮົາສາມາດໃຊ້ໄດ້ໜື່ງຕົວປ່ຽນ ເຖິງຢ່າງໄດ ກໍ່ຕາມ ຖ້າເຮົາມີຫລາຍລາຍການ ເຮົາຕ້ອງປະກາດຕົວປ່ຽນເປັນ ແບບ Array ແທນ

1. Array ໜຶ່ງມິຕີ

Student Name Name(1) Name(2) Name(3) Name(4)

2. Array ສອງມິຕີ

Name(1,1) Name(1,2) Name(1,3) Name(1,4)
Name(2,1) Name(2,2) Name(2,3) Name(2,4)
Name(3,1) Name(3,2) Name(3,3) Name(3,4)

3. ການປະກາດ Array ໜຶ່ງມິຕີ
ແບບໂຄ້ດ:

Dim arrayName(subscript) as dataType 

ຕົວຢ່າງ:

Dim CusName(10) as String
CusName(1) CusName(2) CusName(3) CusName(4) CusName(5)
CusName(6) CusName(7) CusName(8) CusName(9) CusName(10)

[Read more…]

Sunday, September 17, 2017

ການສ້າງ Function ແລະ Sub Procedure (VB6 Lesson 12)

ໃນການຂຽນ Function ແລະ Sub Procedure ໃນ Visual Basic 6 ມີແບບຂຽນຄື:
1. ການສ້າງ Function
ແບບໂຄ້ງສ້າງ:

    Public  Function functionName (Arg As dataType,..........) As dataType
    ຫລື
    Private  Function functionName (Arg As dataType,..........) As dataType

Public ແມ່ນຕົວຊີ້ບອກໃຫ້ Function ນັ້ນ ສາມາດເອີ້ນໃຊ້ໄດ້ໃນ Project ນັ້ນ
ຕົວຢ່າງໂປຣແກຣມ ໃຊ້ Function

Public Function FV(PV As Variant, i As Variant, n As Variant) As Variant
'Formula to calculate Future Value(FV)
'PV denotes Present Value 
FV = PV * (1 + i / 100) ^ n
End Function 
Private Sub compute_Click()
'This procedure will calculate Future Value 
Dim FutureVal As Variant
Dim PresentVal As Variant
Dim interest As Variant
Dim period As Variant
PresentVal = PV.Text
interest = rate.Text
period = years.Text 
'calling the function
FutureVal = FV(PresentVal, interest, period)
MsgBox ("The Future Value is" & FutureVal)
End Sub 

[Read more…]

Thursday, September 14, 2017

ການນຳໃຊ້ String Manipulation Functions (VB6 Lesson 11)

ໃນບົດຮຽນນີ້ ເຮົາຈະແນະນຳການໃຊ້ String Manipulation Functions ເຊັ່ນ: Len, Right, Left, Mid, Trim, Ltrim, Rtrim, Ucase, Lcase, Instr, Val, Str ,Chr and Asc.

1. The Len Function
ເປັນການນັບເອົາລວງຍາວ ຫລື ຈຳນວນອັກສອນ ຕ່າງໆ
syntax:

Len (“Phrase”)

ຕົວຢ່າງ:

Len (VisualBasic) = 11 ແລະ Len (welcome to VB tutorial) = 22

2. The Right Function
ເປັນການເອົາຂໍ້ມູນອອກຈາກເບື້ອງຂວາ ໂດຍລະບຸ ຕຳແຫນ່ງທີ່ຕ້ອງການ
syntax:

Right (“Phrase”, n)

ຕົວຢ່າງ:

Right(“Visual Basic”, 4) = asic

3. The Left Function
ເປັນການເອົາຂໍ້ມູນອອກຈາກເບື້ອງຊ້າຍ ໂດຍລະບຸ ຕຳແຫນ່ງທີ່ຕ້ອງການ
syntax:

Left(“Phrase”, n)

ຕົວຢ່າງ:

Left (“Visual Basic”, 4) = Visu

[Read more…]

Wednesday, September 13, 2017

ໂປຣແກຣມ ແປງຈາກ Bin ເປັນ Hex

ໂປຣແກຣມ ແປງຈາກ Bin ເປັນ Hex ແລະ ຍັງສາມາດແປງ ຈາກ Hex ມາເປັນ Bin ຄືນໄດ້
Image does not exist: https://image.ibb.co/bFmk8a/bin2hex.png
ໂຄ້ດຂອງໂປຣແກຣມນີ້
[Read more…]

Tuesday, September 12, 2017

ການໃຊ້ Built-in Functions (VB6 Lesson 10)

ໃນ Visual Basic 6 ມີ Built-in Functions , Funcrion ແມ່ນມີຄ້າຍຄື procedure ຈຸດປະສົງຫລັກຂອງ Function ແມ່ນ ຮັບຂໍ້ມູນຈາກ ຜູ້ໃຊ້ ແລະ ຄືນຄ່ານັ້ນອອກມາ
ໃນ Visual Basic 6 ມີ Built-in Functions ມີ 2 ແບບ
syntax:

FunctionName (arguments)

guments ເປັນຄ່າທີ່ ປ້ອນໃສ່ ແລະ ຜ່ານ Funcrion
ໃນບົດຮຽນນີ້ເຮົາຈະຮຽນສອງ Funcrion ຄື MsgBox( ) ແລະ InputBox ( )
1. MsgBox ( ) Function
ຮູບແບບໂຄ້ດ

yourMsg=MsgBox(Prompt, Style Value, Title) 

ຄ່າຂອງ Style Value:
Image does not exist: https://image.ibb.co/gQyApF/Style_Values.png
ຕົວຢ່າງ:

yourMsg=MsgBox( "Click OK to Proceed", 1, "Startup Menu")
             and yourMsg=Msg("Click OK to Proceed". vbOkCancel,"Startup Menu") 

yourMsg ແມ່ນຕົວປ່ຽນທີ່ຮັບຄ່າມາຈາກ MsgBox Function ຊື່ງຄ່າທີ່ໄດ້ຮັບມີຫລາຍຄ່າດັ່ງລຸ່ມນີ້
[Read more…]

Monday, September 11, 2017

ການໃຊ້ Looping (VB6 Lesson 9)

ໃນ ພາສາ Visual Basic 6 ມີຮູບແບບການ Loop ຢູ່ 5 ແບບ
1. ແບບ Do Loop
ແບບ Do Loop statements ມີ 4 ແບບ ທີ່ຕ່າງກັນກັນ:
a)

Do While condition
     Block of one or more VB statements
     Loop 

b)

Do
    Block of one or more VB statements
     Loop While condition 

c)

Do Until condition
              Block of one or more VB statements
       Loop 

d)

Do
     Block of one or more VB statements
       Loop Until condition 

[Read more…]

Friday, September 8, 2017

ການນຳໃຊ້ Select Case (VB6 Lesson 8)

Select Case ຄືການຄວບຄຸມ ຂອງເງືອນໄຂ ຄືກັນກັບ if else then ແຕ່ ມັນຈະໃຊ້ງ່າຍກວ່າ ຊຶ່ງມີ syntax ຂອງ Select Case ດັ່ງລຸ່ມນີ້

Select Case expression
    Case value1
	Block of one or  more VB statements

	Case value2
	Block of one or more VB Statements
    Case Else
	Block of one or more VB Statements
End Select

ຕົວຢ່າງ:

Dim grade As String
Private Sub Compute_Click( )
grade=txtgrade.Text
Select Case grade
Case "A"
result.Caption="High Distinction"
Case "A-"
result.Caption="Distinction"
Case "B"
result.Caption="Credit"
Case "C"
result.Caption="Pass"
Case Else
result.Caption="Fail"
End Select
End Sub

Subscribe

  • RSS Atom

ອອນລາຍ: 1 | ມື້ນີ້: 14 | ວານນີ້: 55 | ທິດນີ້: 967 | ເດືອນນີ້: 1019 | ປີນີ້: 15729 | ລວມ: 82832