0% found this document useful (0 votes)
25 views2 pages

Base Conversion

This document contains the code for a base conversion calculator application. The code handles clicking the compute and reset buttons, validating user input, performing the base conversion calculation, and displaying results. It also contains code to allow the user to select their own background color and view about information for the application.

Uploaded by

Aiza Caboles
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Base Conversion

This document contains the code for a base conversion calculator application. The code handles clicking the compute and reset buttons, validating user input, performing the base conversion calculation, and displaying results. It also contains code to allow the user to select their own background color and view about information for the application.

Uploaded by

Aiza Caboles
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Public Class frmBC

Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnCompute.Click
Try
If cbxBase.SelectedIndex <> 0 Then
If txtInput.Text > 0 Then
Dim intInput As Double = txtInput.Text
Dim strBase As String = cbxBase.Text
Dim intRemainder As Double
Dim strAns As String
Do Until intInput = 0
intRemainder = intInput Mod strBase
intInput \= strBase
strAns = intRemainder & strAns
Loop
txtOutput.Text = "The base conversion of " & txtInput.Text & " to
base " & cbxBase.Text _
& " is " & strAns & "."
Else
MsgBox("Please input values greater than zero ONLY!!", vbOK +
vbCritical, "Error!!")
End If
Else
MsgBox("Please select a base to convert to.", vbOK + vbCritical,
"Error!!")
End If
Catch ex As Exception
MsgBox(ex.Message, vbOK + vbCritical, "Error!!")

End Try
Me.BackColor = Color.BlanchedAlmond
MainMenuStrip.BackColor = Color.Bisque
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnReset.Click
cbxBase.SelectedIndex = 0
txtInput.Clear()
txtInput.Focus()
txtOutput.Clear()
Me.BackColor = Color.AliceBlue
End Sub

Private Sub LetMeChooseMyOwnColorDammitToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
LetMeChooseMyOwnColorDammitToolStripMenuItem.Click
If ColorDialog1.ShowDialog = DialogResult.OK Then
Me.BackColor = ColorDialog1.Color
End If
End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles AboutToolStripMenuItem.Click
frmAbout.Show()
End Sub
End Class

You might also like