•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 456,489 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,731 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 911 | Replies: 3
![]() |
| |
•
•
Join Date: Sep 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I need help figuring out how to get the value of my text boxes into the variables I have declared (in bold) , any suggestions would be appreciated:
(/code) Option Explicit On
Option Strict On
Imports System.Convert
Public Class frmMain
Inherits System.Windows.Forms.Form
Private mlblInitialValue As Double
Private mlblSalvageValue As Double
Private mlblAssetLife As Single
Private mdblTotalDepreciation As Double
Private mdblAnnualDepreciation As Double
mlblInitialValue = (txtInitialValue.Text)
mlblSalvageLife = (txtSalvageLife.Text)
mlblAssetLife = (txtSalvageLife.Text)
mdblTotalDepreciation = mlblInitialValue - mlblSalvageLife
mdblAnnualDepreciation = mdblTotalDepreciation / mdblAssetLife
Private Const cintCol1Start As Integer = 100
Private Const cintCol2Start As Integer = 250
Private Const cintCol3Start As Integer = 400
Private Const cintCol4Start As Integer = 550
Private Const cintColWidth As Integer = 150
Private mfntPrint As Font
Private msngFontHeight As Single
Private msngYPos As Single
Private mfnrPrint As Font(/code)
(/code) Option Explicit On
Option Strict On
Imports System.Convert
Public Class frmMain
Inherits System.Windows.Forms.Form
Private mlblInitialValue As Double
Private mlblSalvageValue As Double
Private mlblAssetLife As Single
Private mdblTotalDepreciation As Double
Private mdblAnnualDepreciation As Double
mlblInitialValue = (txtInitialValue.Text)
mlblSalvageLife = (txtSalvageLife.Text)
mlblAssetLife = (txtSalvageLife.Text)
mdblTotalDepreciation = mlblInitialValue - mlblSalvageLife
mdblAnnualDepreciation = mdblTotalDepreciation / mdblAssetLife
Private Const cintCol1Start As Integer = 100
Private Const cintCol2Start As Integer = 250
Private Const cintCol3Start As Integer = 400
Private Const cintCol4Start As Integer = 550
Private Const cintColWidth As Integer = 150
Private mfntPrint As Font
Private msngFontHeight As Single
Private msngYPos As Single
Private mfnrPrint As Font(/code)
•
•
Join Date: Sep 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
I changed your code to this and added some labels to the form to display the results:
Imports System.convert
Public Class Form1
Inherits System.Windows.Forms.Form
Private mlblInitialValue As Double
Private mlblSalvageValue As Double
Private mlblAssetLife As Single
Private mdblTotalDepreciation As Double
Private mdblAnnualDepreciation As Double
Private Const cintCol1Start As Integer = 100
Private Const cintCol2Start As Integer = 250
Private Const cintCol3Start As Integer = 400
Private Const cintCol4Start As Integer = 550
Private Const cintColWidth As Integer = 150
Private mfntPrint As Font
Private msngFontHeight As Single
Private msngYPos As Single
'Private mfnrPrint As Font(/code)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
mlblInitialValue = (txtInitialValue.Text)
mlblSalvageValue = (txtSalvageLife.Text)
mlblAssetLife = (txtSalvageLife.Text)
mdblTotalDepreciation = mlblInitialValue - mlblSalvageValue
mdblAnnualDepreciation = mdblTotalDepreciation / mlblSalvageValue
Me.lblTotalDeprec.Text = mdblTotalDepreciation.ToString
Me.lblAnnualDeprec.Text = mdblAnnualDepreciation.ToString
End Sub
End Class
•
•
Join Date: Dec 2002
Location: West Virginia
Posts: 405
Reputation:
Rep Power: 6
Solved Threads: 42
Being picky but you should use the following:
or
mlblInitialValue = Double.Parse(txtInitialValue.Text)
mlblSalvageValue = Double.Parse(txtSalvageLife.Text)
mlblAssetLife = Single.Parse(txtSalvageLife.Text) mlblInitialValue = CDbl(txtInitialValue.Text)
mlblSalvageValue = CDbl(txtSalvageLife.Text)
mlblAssetLife = CSng(txtSalvageLife.Text) Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
•
•
Join Date: Sep 2007
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
You should use the following functions when transferring text content to a numeric content
Val()
CDbl()
CSng()
The above will convert the text data into numeric data and then the data will transfer into the variables and then there would be no problem.
Hope the above was useful to you.
Bharat Saboo
Val()
CDbl()
CSng()
The above will convert the text data into numeric data and then the data will transfer into the variables and then there would be no problem.
Hope the above was useful to you.
Bharat Saboo
•
•
•
•
I need help figuring out how to get the value of my text boxes into the variables I have declared (in bold) , any suggestions would be appreciated:
(/code) Option Explicit On
Option Strict On
Imports System.Convert
Public Class frmMain
Inherits System.Windows.Forms.Form
Private mlblInitialValue As Double
Private mlblSalvageValue As Double
Private mlblAssetLife As Single
Private mdblTotalDepreciation As Double
Private mdblAnnualDepreciation As Double
mlblInitialValue = (txtInitialValue.Text)
mlblSalvageLife = (txtSalvageLife.Text)
mlblAssetLife = (txtSalvageLife.Text)
mdblTotalDepreciation = mlblInitialValue - mlblSalvageLife
mdblAnnualDepreciation = mdblTotalDepreciation / mdblAssetLife
Private Const cintCol1Start As Integer = 100
Private Const cintCol2Start As Integer = 250
Private Const cintCol3Start As Integer = 400
Private Const cintCol4Start As Integer = 550
Private Const cintColWidth As Integer = 150
Private mfntPrint As Font
Private msngFontHeight As Single
Private msngYPos As Single
Private mfnrPrint As Font(/code)
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Clearing Text Boxes (VB.NET)
- Help Me In My Code (Visual Basic 4 / 5 / 6)
- Adding the results of two text boxes (Visual Basic Express Edition) (VB.NET)
- The Datagrid: How does one fill text boxes in edit mode with their original content? (ASP.NET)
- Cursor control in text boxes: (HTML and CSS)
- link text boxes with listbox (VB.NET)
- Time out web pages w/text or drop boxes (Networking Hardware Configuration)
Other Threads in the VB.NET Forum
- Previous Thread: Find And Replace DailougBox
- Next Thread: Excel in VB


Hybrid Mode