Ngebuat kalkulator dengan VB

0 comments
Assalamu’alaikum all, pa kabar nih ???

Mudah2 an baek-baek ja and pulsa ny masih banyak… biar forum ne tetep AXIS… (AXIS baek y…)

Oke langsung ja… jika sebelumnya kita dah buat program animasi, X ini kita akan coba ngebuat program kalkulator dengan VB. Untuk lebih jelasnya mari kita ikuti langkah-langkah pembuatan nya.

1. Seperti biasa buka program VB dan buat project baru…


2. Desain form dengan memasukkan textbox dan dua bh commandButton..

3. Selanjutnya untuk commandButton yang pertama, kita akan menjadikannya sebagai fungsia array sebanyak 10 bh dengan cara mengcopy paste control tersebut dan menyusunnya seperti desain dibawah ini

4. Setelah mendesai dan menambahkan fungsi array, sekarang tambahkan enam bh commandButton pada form anda

5. Selanjutnya Listing program…. Ketik listing program dibawah ne

Dim intLeft As Integer

Dim intRight As Integer

Dim intInProg As Integer

Dim intOperator As Integer

Dim intPrevOperator As Integer

Dim intClear As Integer

Private Sub Calculate()

If intInProg = 0 Then

intLeft = Int(Text1.Text)

intInProg = 1

Text1.Text = ""

intPrevOperator = intOperator

Exit Sub

Else

intRight = Int(Text1.Text)

Text1.Text = ""

End If

Select Case intPrevOperator

Case 1

intLeft = intLeft + intRight

intRight = 0

Text1.Text = intLeft

Case 2

intLeft = intLeft - intRight

intRight = 0

Text1.Text = intLeft

Case 3

intLeft = intLeft * intRight

intRight = 0

Text1.Text = intLeft

Case 4

intLeft = intLeft / intRight

intRight = 0

Text1.Text = intLeft

End Select

intPrevOperator = intOperator

intClear = 1

End Sub

Private Sub Command1_Click(Index As Integer)

If intClear = 1 Then

Text1.Text = ""

intClear = 1

End If

If Index <> 10 Then

Text1.Text = Text1.Text & (Index + 0)

Else

Text1.Text = Text1.Text & "0"

End If

End Sub

Private Sub Command2_Click()

Text1.Text = ""

intLeft = 0

intRight = 0

intOperator = 0

intPrevOperator = 0

intInProg = 0

End Sub

Private Sub Command3_Click()

intOperator = 1

Calculate

End Sub

Private Sub Command4_Click()

intOperator = 2

Calculate

End Sub

Private Sub Command5_Click()

intOperator = 3

Calculate

End Sub

Private Sub Command6_Click()

intOperator = 5

Calculate

End Sub

Private Sub Command7_Click()

intOperator = 4

Calculate

End Sub

Private Sub Command8_Click()

Text1.Text = Text1.Text & "."

End Sub

Private Sub Form_Load()

intInProg = False

Text1.Text = ""

Command1(0).Caption = "0"

Command1(1).Caption = "1"

Command1(2).Caption = "2"

Command1(3).Caption = "3"

Command1(4).Caption = "4"

Command1(5).Caption = "5"

Command1(6).Caption = "6"

Command1(7).Caption = "7"

Command1(8).Caption = "8"

Command1(9).Caption = "9"

Command2.Caption = "Delete"

Command3.Caption = "+"

Command4.Caption = "-"

Command5.Caption = "*"

Command6.Caption = "="

Command7.Caption = "/"

Command8.Caption = "."

End Sub

6. TAMAT … run programnya… (akhirnya selesai juga…)

Tampilan program

ngebuat Animasi Emotion dengan VB

0 comments


Assalamu’alaikum all, pa khabar nih ???

Ane doain boy-boy semua tetap berada dalam lindungan Allah SWT yang telah

memberikan kita hidayah (PULSA tentunya…) sehingga kita semua dapat berkumpul bersama-sama di forum ini, tidak lupa pula sha... ups, kok jadi macam ceramah ya ??? Wekekeke... ya sudah lah

Okelah kalaw begitu, langsung aja… sebenarnya ni adalah program pertama ane saat baru belajar pemograman VB, jadi bagi boy-boy yang baru belajar VB (newbies… sama kyak ane… ) mungkin program ne bsa di jadiin alternatif….

Disini kita akan membuat program animasi bergerak-gerak, kesamping, keatas, kebawah, kekanan, tw ke kiri tw kmana jaboy-boy mw.. Untuk lebih jelasnya silahkan ja boy-boy ikutin langkah-langkah pembuatan nya……….

1.Bukalah program VB 6.0, kemudian buatlah project baru…(new project)



2.Desain form dengan memasukkan sebuah timer, dua bh command button dan lima bh image, bukan lima image bh loh… (Oy..jangan lupa masukkan garam nya biar g ambar… he1000X)




3. Kemudian sempurnakan desain form nya dengan menambahkan gambar kedalam control image nya… terserah ja gambarnya…disini ane memasukkan gambar-gambar emotion,,



4. OK… sampai disini pekerjaan desain form dh selesai.. selanjutnya listing program…

( hal yang paling membosankan…) kalaw g mw bosan, silahkan copy paste ja listing program dibawah ne…

Private Sub Command1_Click()

Timer1.Enabled = True

End Sub

Private Sub Command2_Click()

Timer1.Enabled = False

Image1.Visible = True

Image2.Visible = False

Image3.Visible = False

Image4.Visible = False

Image5.Visible = False

End Sub

Private Sub Form_Load()

Timer1.Interval = 350

Timer1.Enabled = False

Form1.BackColor = vbWhite

Command1.Caption = "START"

Command2.Caption = "STOP"

Image1.Visible = True

Image2.Visible = False

Image3.Visible = False

Image4.Visible = False

Image5.Visible = False

End Sub

Private Sub Timer1_Timer()

If Image1.Visible = True Then

Image1.Visible = False

Image2.Visible = True

Image3.Visible = False

Image3.Visible = False

Image4.Visible = False

Image5.Visible = False

ElseIf Image2.Visible = True Then

Image1.Visible = False

Image2.Visible = False

Image3.Visible = True

Image4.Visible = False

Image5.Visible = False

ElseIf Image3.Visible = True Then

Image1.Visible = False

Image2.Visible = False

Image3.Visible = False

Image4.Visible = True

Image5.Visible = False

ElseIf Image4.Visible = True Then

Image1.Visible = False

Image2.Visible = False

Image3.Visible = False

Image4.Visible = False

Image5.Visible = True

ElseIf Image5.Visible = True Then

Image1.Visible = True

Image2.Visible = False

Image3.Visible = False

Image4.Visible = False

Image5.Visible = False

End If

End Sub

5. TAMAT (kayak film ja…) tinggal di run ja program ny dengan menekan F5…


5.JPG

Tampilan program

Oy,, ,hampir lupa… untuk megganti kecepatan animasinya boy-boy smua bsa mengubah interval timer nya sesuai selera Anda….klw pengen cepat perkecil interval timer nya dan sebaliknya…