User Name Password Register
DaniWeb IT Discussion Community
All
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 391,559 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,738 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:
Views: 775 | Replies: 3
Reply
Join Date: Sep 2007
Posts: 2
Reputation: tamik0 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tamik0 tamik0 is offline Offline
Newbie Poster

Need help getting value of text boxes into variables

  #1  
Sep 21st, 2007
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)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1
Reputation: funrunner is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
funrunner funrunner is offline Offline
Newbie Poster

Re: Need help getting value of text boxes into variables

  #2  
Sep 22nd, 2007
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
Reply With Quote  
Join Date: Dec 2002
Location: West Virginia
Posts: 368
Reputation: waynespangler is on a distinguished road 
Rep Power: 6
Solved Threads: 34
waynespangler waynespangler is offline Offline
Posting Whiz

Re: Need help getting value of text boxes into variables

  #3  
Sep 22nd, 2007
Being picky but you should use the following:
        mlblInitialValue = Double.Parse(txtInitialValue.Text)
        mlblSalvageValue = Double.Parse(txtSalvageLife.Text)
        mlblAssetLife = Single.Parse(txtSalvageLife.Text)
or
        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.
Reply With Quote  
Join Date: Sep 2007
Posts: 7
Reputation: bharatsaboo is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
bharatsaboo bharatsaboo is offline Offline
Newbie Poster

News Re: Need help getting value of text boxes into variables

  #4  
Sep 23rd, 2007
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


Originally Posted by tamik0 View Post
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)
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb VB.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 9:57 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC