Hi,
How can i get the program to detect if cancel was clicked? Right now when i click cancel the inputbox does not close and simply comes back up saying please enter a number. Do i have to do something boolean related or something?
Code:'Developer- John Nelson 'Date- Feb 10, 2012 'Application Name- Hawaainn Average Tempeture 'The windows application is written for the hawaniin tourism bosard with the task of calculationting 'The average yearly tempurture in the hawaiin Islands for one year Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load out.Text = "" End Sub Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click 'This will close the program when clicked. Close() End Sub Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click 'This code will ask the user to input 12 temperutres, and it will then calculate them. Dim dectemptotalloop As Decimal Dim decave As Decimal Dim stroutputmessage As String = "The average tempo for HI this was " 'Loop Strucure function dectemptotalloop = calclateloop() 'ave temp calculation decave = Calculateavetemp(dectemptotalloop) 'output label out.Text = stroutputmessage & decave.ToString("G") End Sub Private Function calclateloop() 'This section will be the loop function. It will calculate the **** and all that. Dim strcancelclicked As String = "" Dim dectotaloftemps As Decimal Dim decmaxentry As Decimal = 12 Dim deccurrententries As Decimal Dim strentryhold As String Dim strinputmessage As String = "Please enter the average temperature of the month" Dim strerrormessage As String = "Please enter a number or you did not enter up to 12 months" Do Until deccurrententries = decmaxentry strentryhold = InputBox(strinputmessage) If IsNumeric(strentryhold) Then temp.Items.Add(strentryhold) dectotaloftemps += Convert.ToDecimal(strentryhold) deccurrententries += 1 Else MsgBox(strerrormessage) End If Loop Return dectotaloftemps End Function Private Function Calculateavetemp(ByVal decave As Decimal) Dim decavetemp As Decimal decavetemp = decave / 12 Return decavetemp End Function End Class




Reply With Quote