By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Need Text Box Help

P: 3
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 mlblInitialValue As Double
Private mlblSalvageValue 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
Sep 20 '07 #1
Share this Question
Share on Google+
3 Replies


QVeen72
Expert 100+
P: 1,445
I need to store the values ...
Hi,

Write the code in LostFocus of all the TextBox :
ex:
Expand|Select|Wrap|Line Numbers
  1. mlblInitialValue =Val(txtAssetLife.Text)
  2.  
Regards
Veena
Sep 20 '07 #2

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

Expand|Select|Wrap|Line Numbers
  1. Option Explicit On 
  2. Option Strict On
  3.  
  4. Imports System.Convert
  5.  
  6. Public Class frmMain
  7.     Inherits System.Windows.Forms.Form
  8.  
  9.  
  10.     Private mlblInitialValue As Double
  11.     Private mlblSalvageValue As Double
  12.     Private mlblAssetLife As Single
  13.     Private mdblTotalDepreciation As Double
  14.     Private mdblAnnualDepreciation As Double
  15.  
  16.  
  17.     mlblInitialValue = (txtInitialValue.Text)
  18.     mlblSalvageLife = (txtSalvageLife.Text)
  19.     mlblAssetLife = (txtSalvageLife.Text)
  20.  
  21.     mdblTotalDepreciation = mlblInitialValue - mlblSalvageLife
  22.     mdblAnnualDepreciation = mdblTotalDepreciation / mdblAssetLife
  23.  
  24.  
  25.  
  26.     Private Const cintCol1Start As Integer = 100
  27.     Private Const cintCol2Start As Integer = 250
  28.     Private Const cintCol3Start As Integer = 400
  29.     Private Const cintCol4Start As Integer = 550
  30.     Private Const cintColWidth As Integer = 150
  31.  
  32.     Private mfntPrint As Font
  33.     Private msngFontHeight As Single
  34.     Private msngYPos As Single
  35.     Private mfnrPrint As Font
Sep 20 '07 #3

VBPhilly
P: 95
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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtInitialValue_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtInitialValue.TextChanged
  2.  
  3.    mlblInitialValue = (txtInitialValue.Text)
  4.  
  5. End Sub
  6.  
Sep 20 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.