Aplikasi yang kita buat ini, masih sangat sederhana, tujuannya adalah untuk mempelajari cara untuk mempelajari fungsi if then elseif di Gambas.
Buat design aplikasi tiket kereta api seperti gambar dibawah ini
design form tiket kereta api

1 buah combobox
Isi list combobox dengan Yogyakarta, Jakarta dan Malang.
7 buah TextBox
1 buah Button
ubah property text button menjadi hitung.

Klik dua kali di form kosong, tambahkan script dibawah ini, agar nilai di TextBox 1 sampai 7 dihilangkan

TextBox1.Clear
TextBox2.Clear
TextBox3.Clear
TextBox4.Clear
TextBox5.Clear
TextBox6.Clear
TextBox7.Clear

klik dua kali pada tombol Hitung, lalu paste script dibawah ini

Dim harga As Integer
Dim jumlah As Integer
Dim total As Integer
 
  TextBox3.Text = TextBox1.Text
  If ComboBox1.Text = "Jakarta" Then 
  TextBox4.Text = "Jakarta"
  TextBox5.Text = 120000
  Endif
  If ComboBox1.Text = "Yogyakarta" Then
    TextBox4.Text = "Yogyakarta"
    TextBox5.Text = 150000
  Endif
    If ComboBox1.Text = "Malang" Then
    TextBox4.Text = "Malang"
    TextBox5.Text = 200000
  Endif
 
  TextBox6.text = TextBox2.Text
  jumlah = TextBox2.text
  harga = TextBox5.Text
  total = jumlah * harga
  TextBox7.Text = total

Coba jalankan aplikasi Tiket Kereta Api dengan menekan tombol F5 di keyboard.
tampilan aplikasi tiket kereta api

Download :

Download “Aplikasi Tiket Kereta Api”

keretaapi-0.0.1.tar.gz – Downloaded 1938 times – 178.00 B

Join the Conversation

1 Comment

Your email address will not be published. Required fields are marked *

  1. Hello,

    My name is Ann and I represent at AdBrainer ad agency. We offer a CPM monetization solution for websites across the web. Today, I would like to connect with you and learn more about your programmatic needs. At the moment, we are interested in your banner ad placements to promote our ad campaigns.

    If this strikes as something you might be interested in, please don’t hesitate to drop me a line.