[size=2]
[/size][size=2][color=#0000ff]Private[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size][size=2] TextBoxContactNumber_KeyPress([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Object[/color][/size][size=2], [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Windows.Forms.KeyPressEventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2] TextBoxContactNumber.KeyPress
[/size][size=2][color=#008000]'Allows only numeric values into the ContactNumber textbox
[/color][/size][size=2][/size][size=2][color=#0000ff]If[/color][/size][size=2] e.KeyChar.IsNumber(e.KeyChar) = [/size][size=2][color=#0000ff]False[/color][/size][size=2] [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]e.Handled = [/size][size=2][color=#0000ff]True
[/color][/size][size=2][/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If
[/color][/size][size=2][/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size]
[size=2][color=#0000ff]
DavidT_macktool said:I have used this to convert to integer
label1.Text = CInt(textbox1.Text) - (2 * CInt(textbox2.Text))
Or to decimal:
label1.Text = CDec(textbox1.Text) - (2 * CDec(textbox2.Text))
Label1.Text = Convert.ToString(Convert.ToDecimal(Textbox1.Text) - (2D * Convert.ToDecimal(Textbox2.Text)))
Dim myTextbox as Textbox = CType(sender, Textbox)
JuggaloBrotha said:............
also i've heard (not actually read) that in the final release of vs2005 these functions will no longer be supported:
CInt
CBool
CDec
CStr
etc....
as they do recommend the Convert & CType functions be used in .Net
Private Sub txtClimbRanks_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtClimbRanks.TextChanged
climbRanks = txtClimbRanks.Text
txtClimbTotal.Text = SetSkillTotal(climbRanks, climbMisc, climbAbility)
End Sub
Private Sub txtClimbMisc_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtClimbMisc.TextChanged
climbMisc = txtClimbMisc.Text
txtClimbTotal.Text = SetSkillTotal(climbRanks, climbMisc, climbAbility)
End Sub
Private Sub txtClimbAbility_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtClimbAbility.TextChanged
climbAbility = txtClimbAbility.Text
txtClimbTotal.Text = SetSkillTotal(climbRanks, climbMisc, climbAbility)
End Sub
[font=Courier New][color=blue]Private[/color] [color=blue]Function[/color] SetSkillTotal([color=blue]ByVal[/color] pRanks [color=blue]As[/color] [color=blue]String[/color], [color=blue]ByVal[/color] pMisc [color=blue]As[/color] [color=blue]String[/color], [color=blue]ByVal[/color] pAbility [color=blue]As[/color] [color=blue]String[/color])[/font]
[font=Courier New] [color=blue]Dim[/color] intRanks [color=blue]As Integer[/color] = pRanks[/font]
[font=Courier New] [color=blue]Dim[/color] intMisc [color=blue]As Integer[/color] = pMisc[/font]
[font=Courier New] [color=blue]Dim[/color] intAbility [color=blue]As Integer[/color] = pAbility[/font]
[font=Courier New] [color=blue]Dim[/color] intTotal [color=blue][color=blue]As[/color] Integer[/color][/font]
[font=Courier New][color=#0000ff] [/color][color=black]intTotal = intRanks + intMisc + intAbility[/color][/font]
[font=Courier New] [color=blue]Return[/color] intTotal[/font]
[font=Courier New] [color=blue]End[/color] [color=blue]Function[/color][/font]