Re: VB. Net String conversion Exception Hanlder message

  • From: "Marvin Hunkin" <startrekcafe@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 28 Sep 2008 22:39:13 +1000

        Hi.
here's the line of code where it is not liking it.
line 43:

costDecimal = Decimal.Parse(costTextBox.Text)


and will then copy the exception error log as well.

System.FormatException was unhandled
  Message="Input string was not in a correct format."
  Source="mscorlib"
  StackTrace:
       at System.Number.StringToNumber(String str, NumberStyles options, 
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
       at System.Number.ParseDecimal(String value, NumberStyles options, 
NumberFormatInfo numfmt)
       at System.Decimal.Parse(String s)
       at Finance.financeForm.calculateButton_Click(Object sender, EventArgs 
e)
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.ButtonBase.OnKeyUp(KeyEventArgs kevent)
       at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
       at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
       at System.Windows.Forms.Control.WmKeyChar(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at 
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& 
m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, 
Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& 
msg)
       at 
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
 
dwComponentID, Int32 reason, Int32 pvLoopData)
       at 
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 
reason, ApplicationContext context)
       at 
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, 
ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at 
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at 
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at 
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
 
commandLine)
       at Finance.My.MyApplication.Main(String[] Args)
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] 
args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence 
assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext 
executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:


cheers Marvin.
----- Original Message ----- 
From: "Ricks Place" <OFBGMail@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Sunday, September 28, 2008 10:31 PM
Subject: Re: VB. Net String conversion Exception Hanlder message


Hi Marv:
Just send the Error Message and the line of code, or short code block,
related to the message for help please.
Rick USA
----- Original Message ----- 
From: "Marvin Hunkin" <startrekcafe@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Sunday, September 28, 2008 8:02 AM
Subject: VB. Net String conversion Exception Hanlder message


> Hi.
> now, for my finance project, got an exception error, and says some thing
> about conversion string.
> how can i fix this one, and if any one can help, would be appreciative. vb
> programming book.
> for my vb class.
> if any one can help me out, and show me how to fix the problem, will go
> and
> show you the code and the exception helper window.
>
>
> 'Program:   Finance
> 'Programmer:    Marvin Hunkin
> 'Date:  Tuesday September 9 2008
> 'Description:   Enter beginning, ending and cost of living for a
> management
> company.
> 'Calculate  the beginning, ending and cost of living, display the average
> inventory,  and the turnover.
>
>
> Public Class financeForm
>
>
>    'Constant Declaration
>
>    Const yearInteger As Integer = 365
>
>
>
>
>
>
>
>
>
>    Private Sub calculateButton_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles calculateButton.Click
>
>
>        'Calculate Beginning Inventory, Ending Inventory and Cost Of Goods
>
>        Dim beginDecimal As Decimal
>        Dim endDecimal As Decimal
>        Dim costDecimal As Decimal
>        Dim averageDecimal As Decimal
>        Dim turnoverInteger As Integer
>
>
>        'Convert variables.
>
>        With Me
>
>
>
>            beginDecimal = Decimal.Parse(beginTextBox.Text)
>            endDecimal = Decimal.Parse(endTextBox.Text)
>            costDecimal = Decimal.Parse(costTextBox.Text)
>            averageDecimal = Decimal.Parse(averageTextBox.Text)
>            turnoverInteger = Integer.Parse(turnoverTextBox.Text)
>
>
>            'Calculate Finance Details.
>
>
>
>
>
>
>
>            averageDecimal = beginDecimal * endDecimal * costDecimal /
> yearInteger
>            turnoverInteger = beginDecimal * endDecimal / yearInteger
>
>
>            Try
>
>
>
>
>            Catch beginException As FormatException
>
>
>                MessageBox.Show("Entry must be numeric.", "Data Errror", _
>                                MessageBoxButtons.OK,
> MessageBoxIcon.Exclamation)
>
>
>            Catch endException As FormatException
>
>
>                MessageBox.Show("Entry must be numeric.", "Data Errror", _
>                                MessageBoxButtons.OK,
> MessageBoxIcon.Exclamation)
>
>
>
>
>
>
>            Catch costException As FormatException
>
>
>                MessageBox.Show("Entry must be numeric.", "Data Errror", _
>                                MessageBoxButtons.OK,
> MessageBoxIcon.Exclamation)
>
>
>
>
>
>
>
>
>                'Format Text Boxes.
>
>                .beginTextBox.Text = beginDecimal.ToString("C")
>                .endTextBox.Text = endDecimal.ToString("C")
>                .costTextBox.Text = costDecimal.ToString("C")
>                .averageTextBox.Text = averageDecimal.ToString("C")
>                .turnoverTextBox.Text = turnoverInteger.ToString("N")
>
>
>                With beginTextBox
>
>
>                    .Focus()
>                    .SelectAll()
>
>                End With
>
>
>
>            End Try
>
>
>        End With
>
>
>
>
>    End Sub
>
>    Private Sub clearButton_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles clearButton.Click
>
>
>
>        'Clear Text boxes.
>
>        beginTextBox.Clear()
>
>    End Sub
>
>    Private Sub exitButton_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles exitButton.Click
>
>
>        'Exit the project.
>
>        Me.Close()
>
>    End Sub
> End Class
>
>
> 'Program:   Finance
> 'Programmer:    Marvin Hunkin
> 'Date:  Tuesday September 9 2008
> 'Description:   Enter beginning, ending and cost of living for a
> management
> company.
> 'Calculate  the beginning, ending and cost of living, display the average
> inventory,  and the turnover.
>
>
> Public Class financeForm
>
>
>    'Constant Declaration
>
>    Const yearInteger As Integer = 365
>
>
>
>
>
>
>
>
>
>    Private Sub calculateButton_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles calculateButton.Click
>
>
>        'Calculate Beginning Inventory, Ending Inventory and Cost Of Goods
>
>        Dim beginDecimal As Decimal
>        Dim endDecimal As Decimal
>        Dim costDecimal As Decimal
>        Dim averageDecimal As Decimal
>        Dim turnoverInteger As Integer
>
>
>        'Convert variables.
>
>        With Me
>
>
>
>            beginDecimal = Decimal.Parse(beginTextBox.Text)
>            endDecimal = Decimal.Parse(endTextBox.Text)
>            costDecimal = Decimal.Parse(costTextBox.Text)
>            averageDecimal = Decimal.Parse(averageTextBox.Text)
>            turnoverInteger = Integer.Parse(turnoverTextBox.Text)
>
>
>            'Calculate Finance Details.
>
>
>
>
>
>
>
>            averageDecimal = beginDecimal * endDecimal * costDecimal /
> yearInteger
>            turnoverInteger = beginDecimal * endDecimal / yearInteger
>
>
>            Try
>
>
>
>
>            Catch beginException As FormatException
>
>
>                MessageBox.Show("Entry must be numeric.", "Data Errror", _
>                                MessageBoxButtons.OK,
> MessageBoxIcon.Exclamation)
>
>
>            Catch endException As FormatException
>
>
>                MessageBox.Show("Entry must be numeric.", "Data Errror", _
>                                MessageBoxButtons.OK,
> MessageBoxIcon.Exclamation)
>
>
>
>
>
>
>            Catch costException As FormatException
>
>
>                MessageBox.Show("Entry must be numeric.", "Data Errror", _
>                                MessageBoxButtons.OK,
> MessageBoxIcon.Exclamation)
>
>
>
>
>
>
>
>
>                'Format Text Boxes.
>
>                .beginTextBox.Text = beginDecimal.ToString("C")
>                .endTextBox.Text = endDecimal.ToString("C")
>                .costTextBox.Text = costDecimal.ToString("C")
>                .averageTextBox.Text = averageDecimal.ToString("C")
>                .turnoverTextBox.Text = turnoverInteger.ToString("N")
>
>
>                With beginTextBox
>
>
>                    .Focus()
>                    .SelectAll()
>
>                End With
>
>
>
>            End Try
>
>
>        End With
>
>
>
>
>    End Sub
>
>    Private Sub clearButton_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles clearButton.Click
>
>
>
>        'Clear Text boxes.
>
>        beginTextBox.Clear()
>
>    End Sub
>
>    Private Sub exitButton_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles exitButton.Click
>
>
>        'Exit the project.
>
>        Me.Close()
>
>    End Sub
> End Class
>
> graphic 94  Solution Explo... Data SourcetTextBox.Text)
> averageTextBox.Text) Properties
> (turnoverTextBox.Text) graphic 545
> graphic 545
> graphic 932
> graphic 756  graphic 692
>
>
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: