exception Handeling


The problem I am haveing is that will accept alpha charicters on user input which creates an exception
error and crashes the program and I have no Idea how to fix this. my code for my change follows.
Any Assistance would be appreciater.


Public Class Form1 Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click Dim Leftover As Integer Leftover = Integer.Parse(txtEnterPennies.Text) txtDollars.Text = (Leftover \ 100).ToString Leftover = Leftover Mod 100 txtQuarters.Text = (Leftover \ 25).ToString Leftover = Leftover Mod 25 txtDimes.Text = (Leftover \ 10).ToString Leftover = Leftover Mod 10 txtNickels.Text = (Leftover \ 5).ToString Leftover = Leftover Mod 5 txtPennies.Text = Leftover.ToString End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click txtEnterPennies.Text = "" txtDollars.Text = "" txtQuarters.Text = "" txtDimes.Text = "" txtNickels.Text = "" txtPennies.Text = "" End Sub End Class

Dick
This post has been edited by simsjunkie2003: 11 December 2007 - 03:46 PM
Posted On: Monday 24th of December 2012 01:09:34 AM Total Views:  245
View Complete with Replies

RELATED TOPICS OF Visual Basic PROGRAMMING LANGUAGE




Re: how to handle primary key exception in vb 6.0

hi i am a beginner in vb programming. i am developing a application in vb 6.0 with access database.and there is one table having a field primary key.when i am going to insert same data that the field already it shows a error message " Run-time error '-2147467259(80004005)': " can any one tell me how to handle this error by displaying a messagebox.
VIEWS ON THIS POST

192

Posted on:

Tuesday 23rd October 2012
View Replies!

Database to array?

Good Afternoon Everyone; My question is dealing more with VBA in Excel, however I could not find enough information in Excel groups. This is my question: I want to pull data from a huge database, let's say a table of ...
VIEWS ON THIS POST

96

Posted on:

Sunday 11th November 2012
View Replies!

Automatic Software Update Question

I am implementing and automatic software update system for my app and have a 'philosophical' question on its implementation. The user can choose daily, weekly or monthly checks (or never of course). The question is - should I check ...
VIEWS ON THIS POST

109

Posted on:

Thursday 15th November 2012
View Replies!

Lost Projects (More)

Re: the projects that would no longer open after being moved (actually that folder on the server had to be renamed)... the suggestion was: The paths in the vbp file may be referencing absolute paths, or may be referencing relative ...
VIEWS ON THIS POST

70

Posted on:

Tuesday 20th November 2012
View Replies!

Very strange keyboard behavior

Please start Visual Basic (Standard EXE) and press F5. You see an empty form. 1) Press and hold 'CTRL' + 'A' and then press 'F1'. You shouldn't hear any beep. I think that's normal. 2) Press and hold 'CTRL' + ...
VIEWS ON THIS POST

207

Posted on:

Tuesday 20th November 2012
View Replies!

Drag And Drop (retry)

I want to use Drag And Drop to handle items in a FileListBox. By selecting an item from the FileListBox I want to Drag it to another FikeKistBox and Drop it there. The action is a FileCopy. Now I ...
VIEWS ON THIS POST

194

Posted on:

Tuesday 20th November 2012
View Replies!

What is the debuggers issue?

Ok my earlier post was that I could not get the password to work. Since, I have checked again using the debug feature and it highlights this line of code. Set PartNumber = DB.OpenRecordset(SQLselect & SQLwhere) I am lost and tired, any help would be appreciated..... Private Sub SaveValuesToPartNumberTable() Static DB As Database, PartNumber As DAO.Recordset Dim SQLselect As String Dim SQLwhere As String Dim WireXPos As Double, ElectrodeYPos As Double, ElectrodePitch As Double WireXPos = Val(txtWireXValue.Text) ElectrodeYPos = Val(txtElectrodeYValue.Text) ElectrodePitch = Val(txtPitch.Text) Set DB = Workspaces(0).OpenDatabase(sMasterDatabasePath & "PartNumber.mdb", False, False, ";pwd=Hollister") SQLselect = "SELECT * FROM [PartNumber] " SQLwhere = "WHERE [PartNumber] = " & Chr$(34) & sPartNumber & Chr$(34) Set PartNumber = DB.OpenRecordset(SQLselect & SQLwhere) PartNumber.Edit PartNumber!NominalWireXPosition = WireXPos PartNumber!NominalPinElectrodeYPosition = ElectrodeYPos PartNumber!NominalElectrodePitch = ElectrodePitch PartNumber.Update PartNumber.Close DB.Close End Sub
VIEWS ON THIS POST

162

Posted on:

Wednesday 28th November 2012
View Replies!

WM_QUERYENDSESSION help needed

I have a huge problem with my VB6 program and the WM_QUERYENDSESSION message. I have created a hidden form and use some api calls to catch the end session message. This form is loaded when my application starts. This works fine. In the form_queryUnload I catch the message and the following code gets executed: Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long 'Writelog "WindowProc start " & CStr(uMsg) WindowProc = CallWindowProc(doQuery, hwnd, uMsg, wParam, lParam) Select Case uMsg Case WM_QUERYENDSESSION If (wParam Or ENDSESSION_LOGOFF) = ENDSESSION_LOGOFF Then 'Writelog "WindowProc logoff" 'Do all your saving of data here... LogOffUser Else 'Writelog "WindowProc iets anders" 'do all of your saving of data here.. LogOffUser End If End Select End Function And now my problem. On my windows xp pro develop machine this code works fine. On my test server (windows server 2003) it also works fine. But on a German test server (windows server 2003 r2) it doesn't. The form is started, that's good, but as soon as I log off, or shutdown, the code is not executed and I can't log off my application user correctly. Does anyone have any idea why my code is not executes As you can see in my example code I allready put in some log code, so i'm sure the code to log off is not executed. PLease someone help!!! I running out of time and I can't figure out a solution. I searched several hours on the internet, but no result.
VIEWS ON THIS POST

238

Posted on:

Friday 30th November 2012
View Replies!