473,419 Members | 3,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

DataGridView conversion problems

Imports System.Windows.Forms
Imports System.Convert
Imports Microsoft.VisualBasic.Financial

Public Class Chapter7

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim result As DialogResult
result = MessageBox.Show("Do you really want to quit", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = Windows.Forms.DialogResult.Yes Then
Me.Close()
End If
End Sub

Private Sub DataGridView1_CellContentClick(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
DataGridView1.CellContentClick
End Sub

Private Sub btnCreateAccount_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnCreateAccount.Click
DataGridView1.Columns.Add("Column1", "Loan Amount")
DataGridView1.Columns.Add("Column2", "Annual Interest Rate")
DataGridView1.Columns.Add("Column3", "Term in Years")
DataGridView1.Columns.Add("Column4", "Result Cell")
btnCreateAccount.Enabled = False
btnDeleteAccount.Enabled = True
btnAddAccount.Enabled = True
btnCalculate.Enabled = True
End Sub

Private Sub btnAddRow_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnAddAccount.Click
DataGridView1.Rows.Add()

End Sub
Private Sub btnDeleteRow_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnDeleteAccount.Click
DataGridView1.Rows.RemoveAt(0)
End Sub

Private Sub Chapter7_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
btnDeleteAccount.Enabled = False
btnAddAccount.Enabled = False
btnCalculate.Enabled = False
End Sub

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Dim InterestRate As Double
Dim Payments As Integer
Dim LoanAmountP As Double
Dim LoanAmountC As Double
Dim LoanAmountCell As DataGridViewCell 'reference cell
Dim InterestCell As DataGridViewCell 'reference cell
Dim TermCell As DataGridViewCell 'reference cell
Dim ResultCell As DataGridViewCell 'reference cell
Dim MiddleMan As String
LoanAmountCell = DataGridView1.Rows(0).Cells(0)
MiddleMan = LoanAmountCell.ToString

LoanAmountP = ToDouble(MiddleMan) ' converts the string i just
got from the datagridview cell into a double
InterestCell = DataGridView1.Rows(1).Cells(1)
TermCell = DataGridView1.Rows(2).Cells(2)
InterestRate = (ToDouble(InterestCell.ToString) * 0.1) / 12
Payments = CInt(TermCell.ToString) * 12
'LoanAmountP = (LoanAmountP * InterestRate * Payments) -
LoanAmountP
ResultCell = Pmt(InterestRate, Payments, LoanAmountP)


End Sub
End Class

My pmt is having trouble taking the loanAmountP variable, i was
wondering if anyway has any hints on what the problem might be.

Nov 24 '06 #1
3 3932
You need to post the code for the pmt function.
I'd check and make sure the variable types match.
When you say it's having trouble, what specifically
is it doing, or not doing?

Robin S.
-----------------
"GrispernMix" <Gr*********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Imports System.Windows.Forms
Imports System.Convert
Imports Microsoft.VisualBasic.Financial

Public Class Chapter7

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim result As DialogResult
result = MessageBox.Show("Do you really want to quit", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = Windows.Forms.DialogResult.Yes Then
Me.Close()
End If
End Sub

Private Sub DataGridView1_CellContentClick(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
DataGridView1.CellContentClick
End Sub

Private Sub btnCreateAccount_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnCreateAccount.Click
DataGridView1.Columns.Add("Column1", "Loan Amount")
DataGridView1.Columns.Add("Column2", "Annual Interest Rate")
DataGridView1.Columns.Add("Column3", "Term in Years")
DataGridView1.Columns.Add("Column4", "Result Cell")
btnCreateAccount.Enabled = False
btnDeleteAccount.Enabled = True
btnAddAccount.Enabled = True
btnCalculate.Enabled = True
End Sub

Private Sub btnAddRow_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnAddAccount.Click
DataGridView1.Rows.Add()

End Sub
Private Sub btnDeleteRow_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnDeleteAccount.Click
DataGridView1.Rows.RemoveAt(0)
End Sub

Private Sub Chapter7_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
btnDeleteAccount.Enabled = False
btnAddAccount.Enabled = False
btnCalculate.Enabled = False
End Sub

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Dim InterestRate As Double
Dim Payments As Integer
Dim LoanAmountP As Double
Dim LoanAmountC As Double
Dim LoanAmountCell As DataGridViewCell 'reference cell
Dim InterestCell As DataGridViewCell 'reference cell
Dim TermCell As DataGridViewCell 'reference cell
Dim ResultCell As DataGridViewCell 'reference cell
Dim MiddleMan As String
LoanAmountCell = DataGridView1.Rows(0).Cells(0)
MiddleMan = LoanAmountCell.ToString

LoanAmountP = ToDouble(MiddleMan) ' converts the string i just
got from the datagridview cell into a double
InterestCell = DataGridView1.Rows(1).Cells(1)
TermCell = DataGridView1.Rows(2).Cells(2)
InterestRate = (ToDouble(InterestCell.ToString) * 0.1) / 12
Payments = CInt(TermCell.ToString) * 12
'LoanAmountP = (LoanAmountP * InterestRate * Payments) -
LoanAmountP
ResultCell = Pmt(InterestRate, Payments, LoanAmountP)


End Sub
End Class

My pmt is having trouble taking the loanAmountP variable, i was
wondering if anyway has any hints on what the problem might be.

Nov 24 '06 #2
Hi,

A datagridviewcell's ToString will return the cell type
(datagridviewtextboxcolumn) not is value. Use the cells value instead.

InterestRate = (ToDouble(InterestCell.Value.ToString) * 0.1) / 12
Payments = CInt(TermCell.Value.ToString) * 12

Ken
----------------------
"GrispernMix" <Gr*********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Imports System.Windows.Forms
Imports System.Convert
Imports Microsoft.VisualBasic.Financial

Public Class Chapter7

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim result As DialogResult
result = MessageBox.Show("Do you really want to quit", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = Windows.Forms.DialogResult.Yes Then
Me.Close()
End If
End Sub

Private Sub DataGridView1_CellContentClick(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
DataGridView1.CellContentClick
End Sub

Private Sub btnCreateAccount_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnCreateAccount.Click
DataGridView1.Columns.Add("Column1", "Loan Amount")
DataGridView1.Columns.Add("Column2", "Annual Interest Rate")
DataGridView1.Columns.Add("Column3", "Term in Years")
DataGridView1.Columns.Add("Column4", "Result Cell")
btnCreateAccount.Enabled = False
btnDeleteAccount.Enabled = True
btnAddAccount.Enabled = True
btnCalculate.Enabled = True
End Sub

Private Sub btnAddRow_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnAddAccount.Click
DataGridView1.Rows.Add()

End Sub
Private Sub btnDeleteRow_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnDeleteAccount.Click
DataGridView1.Rows.RemoveAt(0)
End Sub

Private Sub Chapter7_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
btnDeleteAccount.Enabled = False
btnAddAccount.Enabled = False
btnCalculate.Enabled = False
End Sub

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Dim InterestRate As Double
Dim Payments As Integer
Dim LoanAmountP As Double
Dim LoanAmountC As Double
Dim LoanAmountCell As DataGridViewCell 'reference cell
Dim InterestCell As DataGridViewCell 'reference cell
Dim TermCell As DataGridViewCell 'reference cell
Dim ResultCell As DataGridViewCell 'reference cell
Dim MiddleMan As String
LoanAmountCell = DataGridView1.Rows(0).Cells(0)
MiddleMan = LoanAmountCell.ToString

LoanAmountP = ToDouble(MiddleMan) ' converts the string i just
got from the datagridview cell into a double
InterestCell = DataGridView1.Rows(1).Cells(1)
TermCell = DataGridView1.Rows(2).Cells(2)
InterestRate = (ToDouble(InterestCell.ToString) * 0.1) / 12
Payments = CInt(TermCell.ToString) * 12
'LoanAmountP = (LoanAmountP * InterestRate * Payments) -
LoanAmountP
ResultCell = Pmt(InterestRate, Payments, LoanAmountP)


End Sub
End Class

My pmt is having trouble taking the loanAmountP variable, i was
wondering if anyway has any hints on what the problem might be.
Nov 25 '06 #3
Hi,

The DataGridViewCell's ToString method returns the cell type (ie
datagridviewtextboxcell) not its value. Use it's value property instead.

InterestRate = (ToDouble(InterestCell.Value.ToString) * 0.1) / 12
Payments = CInt(TermCell.Value.ToString) * 12

Ken
------------------------
"GrispernMix" <Gr*********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Imports System.Windows.Forms
Imports System.Convert
Imports Microsoft.VisualBasic.Financial

Public Class Chapter7

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim result As DialogResult
result = MessageBox.Show("Do you really want to quit", "Exit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = Windows.Forms.DialogResult.Yes Then
Me.Close()
End If
End Sub

Private Sub DataGridView1_CellContentClick(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
DataGridView1.CellContentClick
End Sub

Private Sub btnCreateAccount_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnCreateAccount.Click
DataGridView1.Columns.Add("Column1", "Loan Amount")
DataGridView1.Columns.Add("Column2", "Annual Interest Rate")
DataGridView1.Columns.Add("Column3", "Term in Years")
DataGridView1.Columns.Add("Column4", "Result Cell")
btnCreateAccount.Enabled = False
btnDeleteAccount.Enabled = True
btnAddAccount.Enabled = True
btnCalculate.Enabled = True
End Sub

Private Sub btnAddRow_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnAddAccount.Click
DataGridView1.Rows.Add()

End Sub
Private Sub btnDeleteRow_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnDeleteAccount.Click
DataGridView1.Rows.RemoveAt(0)
End Sub

Private Sub Chapter7_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
btnDeleteAccount.Enabled = False
btnAddAccount.Enabled = False
btnCalculate.Enabled = False
End Sub

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Dim InterestRate As Double
Dim Payments As Integer
Dim LoanAmountP As Double
Dim LoanAmountC As Double
Dim LoanAmountCell As DataGridViewCell 'reference cell
Dim InterestCell As DataGridViewCell 'reference cell
Dim TermCell As DataGridViewCell 'reference cell
Dim ResultCell As DataGridViewCell 'reference cell
Dim MiddleMan As String
LoanAmountCell = DataGridView1.Rows(0).Cells(0)
MiddleMan = LoanAmountCell.ToString

LoanAmountP = ToDouble(MiddleMan) ' converts the string i just
got from the datagridview cell into a double
InterestCell = DataGridView1.Rows(1).Cells(1)
TermCell = DataGridView1.Rows(2).Cells(2)
InterestRate = (ToDouble(InterestCell.ToString) * 0.1) / 12
Payments = CInt(TermCell.ToString) * 12
'LoanAmountP = (LoanAmountP * InterestRate * Payments) -
LoanAmountP
ResultCell = Pmt(InterestRate, Payments, LoanAmountP)


End Sub
End Class

My pmt is having trouble taking the loanAmountP variable, i was
wondering if anyway has any hints on what the problem might be.
Nov 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: TheSteph | last post by:
Using : Windows 2000 Pro SP4 / VS.NET 2005 / .NET 2.0 / C# - All updates done. I have several bugs when I use the DataGridView : When scrolling (or after scrolling) the grid have these...
130
by: Daniel Manes | last post by:
I'm baffled. I have a column in a SQL Server Express database called "Longitude," which is a float. When I view the table in a DataGridView, some of the numbers, which only have two decimal places...
1
by: romerve | last post by:
Hello; i am having some problems trying to get a form that has a datagridview to refresh after a new record is created. I have a MDI container and menu form and add new record form; the menu...
11
by: dave18 | last post by:
Hello all! I found a solution to my original question, but there's still so much I don't understand about it, I thought I'd give this forum a try. At the very least, maybe it will help someone...
5
by: TheSteph | last post by:
Hi ! I have a DataGridView with a Date (DateTime) Column. When a user edit the cell and change the date I woulk like to allow him to write "081501" and programmatically transform the entered...
1
by: Avedo | last post by:
Hello! I have a form application with a DataGridView, and an Save/Delete and Cancel button. When the application is opened, it is supplied an XML file that may or may not exist, and display the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.