Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Private Sub BtnInput_Click(sender As Object, e As EventArgs) Handles BtnInput.Click
- Dim Pesan As String = "Masukkan Angka"
- Dim Judul As String = "Angka Valid 0-9"
- Dim IsiDefault As Integer = 0
- 'deklarasikan sebuah control InputBox
- 1: Dim userInput As String = InputBox(Pesan, Judul, IsiDefault)
- If Len(userInput) = 0 Then 'jika InputBox kosong
- TxtOutput.Text = IsiDefault
- Else
- 'jika user menginput selain angka
- If Not IsNumeric(userInput) Then
- 'tampilkan DialogBox berisi pesan dan memperbolehkan user menutup dialogbox ini dengan menekan tombol Ok
- MsgBox("Inputan tidak valid, harap masukkan angka 0-9", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Perhatian")
- GoTo 1 'tampilkan ulang InputBox
- Else
- 'jika user menginput angka, maka tampilkan outputnya ke TextBox
- TxtOutput.Text = userInput
- End If
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment