program error

ini adalah salah satu tugas yang terlama pernah saya buat untuk tugas kuliah. semenjak kuliah di ITB saya menemui banyak kesulitan dalam belajar ataupun mengerjakan tugas yang diberikan oleh para dosen yang luar biasa. padahal sebagian dari materi kuliahnya bukan sesuatu yang baru sekali buat saya, tapi mungkin karena sudah terlampau lama saya tidak berkutat lagi di dunia IT secara langsung.

ini program yang menurut saya sudah cukup error karena ketika di eksekusi dengan angka, tampilannya tetap bilang bahwa harus dimasukkan numerik. padahal saya sudah memasukkan numerik.

berikut script program dengan menggunakan visualbasic :

Option Explicit
Dim num1, num2

Private Sub Command1_Click()
num1 = Text2.Text
If Not IsNumeric(num1) Then
MsgBox (“Make sure your conversion is numeric.”)
Exit Sub
End If
Select Case Combo1.Text
Case “Bits”
With Combo2
If .Text = “Bits” Then Text2.Text = num1
If .Text = “Bytes” Then Text2.Text = num1 / 8
If .Text = “Kilobytes” Then Text2.Text = num1 / 8 / 1024
If .Text = “Megabytes” Then Text2.Text = num1 / 8 / 1024 / 1024
If .Text = “Gigabytes” Then Text2.Text = num1 / 8 / 1024 / 1024 / 1024
If .Text = “Terabytes” Then Text2.Text = num1 / 8 / 1024 / 1024 / 1024 / 1024
If .Text = “Petabytes” Then Text2.Text = num1 / 8 / 1024 / 1024 / 1024 / 1024 / 1024
End With
Case “Bytes”
With Combo2
If .Text = “Bits” Then Text2.Text = num1 * 8
If .Text = “Bytes” Then Text2.Text = num1
If .Text = “Kilobytes” Then Text2.Text = num1 / 1024
If .Text = “Megabytes” Then Text2.Text = num1 / 1024 / 1024
If .Text = “Gigabytes” Then Text2.Text = num1 / 1024 / 1024 / 1024
If .Text = “Terabytes” Then Text2.Text = num1 / 1024 / 1024 / 1024 / 1024
If .Text = “Petabytes” Then Text2.Text = num1 / 1024 / 1024 / 1024 / 1024 / 1024
End With
Case “Kilobytes”
With Combo2
If .Text = “Bits” Then Text2.Text = num1 * 1024 * 8
If .Text = “Bytes” Then Text2.Text = num1 * 1024
If .Text = “Kilobytes” Then Text2.Text = num1
If .Text = “Megabytes” Then Text2.Text = num1 / 1024
If .Text = “Gigabytes” Then Text2.Text = num1 / 1024 / 1024
If .Text = “Terabytes” Then Text2.Text = num1 / 1024 / 1024 / 1024
If .Text = “Petabytes” Then Text2.Text = num1 / 1024 / 1024 / 1024 / 1024
End With
Case “Megabytes”
With Combo2
If .Text = “Bits” Then Text2.Text = num1 * 1024 * 1024 * 8
If .Text = “Bytes” Then Text2.Text = num1 * 1024 * 1024
If .Text = “Kilobytes” Then Text2.Text = num1 * 1024
If .Text = “Megabytes” Then Text2.Text = num1
If .Text = “Gigabytes” Then Text2.Text = num1 / 1024
If .Text = “Terabytes” Then Text2.Text = num1 / 1024 / 1024
If .Text = “Petabytes” Then Text2.Text = num1 / 1024 / 1024 / 1024
End With
Case “Gigabytes”
With Combo2
If .Text = “Bits” Then Text2.Text = num1 * 1024 * 1024 * 1024 * 8
If .Text = “Bytes” Then Text2.Text = num1 * 1024 * 1024 * 1024
If .Text = “Kilobytes” Then Text2.Text = num1 * 1024 * 1024
If .Text = “Megabytes” Then Text2.Text = num1 * 1024
If .Text = “Gigabytes” Then Text2.Text = num1
If .Text = “Terabytes” Then Text2.Text = num1 / 1024
If .Text = “Petabytes” Then Text2.Text = num1 / 1024 / 1024
End With
Case “Terabytes”
With Combo2
If .Text = “Bits” Then Text2.Text = num1 * 1024 * 1024 * 1024 * 1024 * 8
If .Text = “Bytes” Then Text2.Text = num1 * 1024 * 1024 * 1024 * 1024
If .Text = “Kilobytes” Then Text2.Text = num1 * 1024 * 1024 * 1024
If .Text = “Megabytes” Then Text2.Text = num1 * 1024 * 1024
If .Text = “Gigabytes” Then Text2.Text = num1 * 1024
If .Text = “Terabytes” Then Text2.Text = num1
If .Text = “Petabytes” Then Text2.Text = num1 / 1024
End With
Case “Petabytes”
With Combo2
If .Text = “Bits” Then Text2.Text = num1 * 1024 * 1024 * 1024 * 1024 * 1024 * 8
If .Text = “Bytes” Then Text2.Text = num1 * 1024 * 1024 * 1024 * 1024 * 1024
If .Text = “Kilobytes” Then Text2.Text = num1 * 1024 * 1024 * 1024 * 1024
If .Text = “Megabytes” Then Text2.Text = num1 * 1024 * 1024 * 1024
If .Text = “Gigabytes” Then Text2.Text = num1 * 1024 * 1024
If .Text = “Terabytes” Then Text2.Text = num1 * 1024
If .Text = “Petabytes” Then Text2.Text = num1
End With
End Select
End Sub

Private Sub Form_Load()
Combo1.AddItem (“Bits”)
Combo1.AddItem (“Bytes”)
Combo1.AddItem (“Kilobytes”)
Combo1.AddItem (“Megabytes”)
Combo1.AddItem (“Gigabytes”)
Combo1.AddItem (“Terabytes”)
Combo1.AddItem (“Petabytes”)

Combo2.AddItem (“Bits”)
Combo2.AddItem (“Bytes”)
Combo2.AddItem (“Kilobytes”)
Combo2.AddItem (“Megabytes”)
Combo2.AddItem (“Gigabytes”)
Combo2.AddItem (“Terabytes”)
Combo2.AddItem (“Petabytes”)
End Sub

Private Sub Label4_Click()
End
End Sub

dan ini adalah tampilan errornya

mungkin ini bukan proram error yang sebenarnya untuk para programmer. punteun kalo salah

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.