| | |
Need help getting value of text boxes into variables
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2007
Posts: 2
Reputation:
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:
Solved Threads: 0
I changed your code to this and added some labels to the form to display the results:
VB.NET Syntax (Toggle Plain Text)
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
Posts: 461
Reputation:
Solved Threads: 56
Being picky but you should use the following:
or
VB.NET Syntax (Toggle Plain Text)
mlblInitialValue = Double.Parse(txtInitialValue.Text) mlblSalvageValue = Double.Parse(txtSalvageLife.Text) mlblAssetLife = Single.Parse(txtSalvageLife.Text)
VB.NET Syntax (Toggle Plain 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:
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)
![]() |
Similar Threads
- 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
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add advanced application array assignment basic binary box button buttons center click code combo connectionstring convert cpu data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall folder forms image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity pan peertopeervideostreaming picturebox picturebox2 port print printpreview record regex reports" reuse right-to-left save savedialog search serial socket sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf xml





