Need Text Box Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tamik0
    New Member
    • Sep 2007
    • 3

    Need Text Box Help

    I need to store the values of my input text boxes into the variables I have declared (in bold) . My text boxes atr txtInitialValue , txtAssetLife and txtSalvageValue . Can anyone help? Here is my code:



    Option Explicit On
    Option Strict On

    Imports System.Convert

    Public Class frmMain
    Inherits System.Windows. Forms.Form


    Private mlblInitialValu e As Double
    Private mlblSalvageValu e As Double
    Private mlblAssetLife As Single



    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
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Originally posted by tamik0
    I need to store the values ...
    Hi,

    Write the code in LostFocus of all the TextBox :
    ex:
    [code=vbnet]
    mlblInitialValu e =Val(txtAssetLi fe.Text)
    [/code]

    Regards
    Veena
    Last edited by Killer42; Sep 21 '07, 05:21 AM. Reason: Reduced excessive quote block

    Comment

    • tamik0
      New Member
      • Sep 2007
      • 3

      #3
      Thanks for the suggestion, I have changed the code but still having trouble getting it to work. Here is my revised code:

      [CODE=vbnet]Option Explicit On
      Option Strict On

      Imports System.Convert

      Public Class frmMain
      Inherits System.Windows. Forms.Form


      Private mlblInitialValu e As Double
      Private mlblSalvageValu e As Double
      Private mlblAssetLife As Single
      Private mdblTotalDeprec iation As Double
      Private mdblAnnualDepre ciation As Double


      mlblInitialValu e = (txtInitialValu e.Text)
      mlblSalvageLife = (txtSalvageLife .Text)
      mlblAssetLife = (txtSalvageLife .Text)

      mdblTotalDeprec iation = mlblInitialValu e - mlblSalvageLife
      mdblAnnualDepre ciation = mdblTotalDeprec iation / 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]
      Last edited by Killer42; Sep 21 '07, 05:20 AM. Reason: Added [CODE=vbnet] tag

      Comment

      • VBPhilly
        New Member
        • Aug 2007
        • 95

        #4
        Originally posted by tamik0
        Thanks for the suggestion, I have changed the code ...
        Double-click the textbox in design to get to the TextChanged event.
        Put your assignment code in there:

        [code=vbnet]
        Private Sub txtInitialValue _TextChanged(By Val sender As System.Object, ByVal e As System.EventArg s) Handles txtInitialValue .TextChanged

        mlblInitialValu e = (txtInitialValu e.Text)

        End Sub
        [/code]
        Last edited by Killer42; Sep 21 '07, 05:20 AM. Reason: Reduced excessive quote block

        Comment

        Working...