Textboxes

ravoll

Well-known member
Joined
Aug 26, 2010
Messages
50
Programming Experience
Beginner
Hi All.
First an explaination of my plans.
I have 6 textboxes set to calculate final drive ratios.Textbox 1 is enabled at form load,all others disabled.
What I want is for the user to enter his number of gears,from 1 to 5,into Textbox1 to enable only the text boxes he will need
for the calculations.
For example If he only has a 3 speed ,then 3 will be entered into Textbox1 and only textboxes 2,3, and 4 will be enabled.

I have it this far,but when I clear textbox 1 the textboxes enabled don't disable, and throws an error."A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll"

Code example provided is for 1 gear for simplicity.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = 1 Then
TextBox2.Enabled = True
Else : TextBox2.Enabled = False
End If
End Sub

What am I doing wrong?
 
any one plz help,............
i have to multiply two matrices,, i used tablelayoutpanel to create no of textboxes i need according to order of matrices by a button,,,........ but the problem is that i can not store value in textboxes bcz they are not present no form when program runs,.......when i write a(1,1)=textbox1.text ,,,,,,.1 is underlined read bcz no textbox is there in form,...... how can i resolve my this issue,..i.e how can take input for textbox that is created as form loads or button is pressed,...........is there any way,.......plz help,,,,,. thanks
 
You could try using an InputBox, which returns a text value to a variable. After creating the textbox, you can copy the value to the textbox's Text property.
Example:
Dim myval As String
myval = InputBox("Enter value here")
'create the textbox
textbox.Text = myval
 
any one plz help,............
i have to multiply two matrices,, i used tablelayoutpanel to create no of textboxes i need according to order of matrices by a button,,,........ but the problem is that i can not store value in textboxes bcz they are not present no form when program runs,.......when i write a(1,1)=textbox1.text ,,,,,,.1 is underlined read bcz no textbox is there in form,...... how can i resolve my this issue,..i.e how can take input for textbox that is created as form loads or button is pressed,...........is there any way,.......plz help,,,,,. thanks
Not to sound rude or anything, but you might want to consider book marking this website: Dictionary.com
 
any one plz help,............
i have to multiply two matrices,, i used tablelayoutpanel to create no of textboxes i need according to order of matrices by a button,,,........ but the problem is that i can not store value in textboxes bcz they are not present no form when program runs,.......when i write a(1,1)=textbox1.text ,,,,,,.1 is underlined read bcz no textbox is there in form,...... how can i resolve my this issue,..i.e how can take input for textbox that is created as form loads or button is pressed,...........is there any way,.......plz help,,,,,. thanks

thanks for reply bro,............i am pasting my code for multiplication of two matrices upto order 5x5,..........it contains two buttons , 3 tablelayout panels each having 5 columns and 5 rows,.........plz use this code in ur pc ,........tell me what i have to do next to get my rersults in tablelayout panel 3 ...i need to submit this as my assignment 6th june,.......plz help me
regards shahid

_____________________________________________________________________________________________________________________________________________
Public Class Form1
Dim a(q, r) As Single
Dim b(s, t) As Single
Dim c(q, t) As Single
Dim f As Integer
Dim g As Integer
Dim h As Integer
Dim c1 As Integer
Dim d As Integer
Dim q As Single
Dim r As Single
Dim s As Integer
Dim t As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim m As Integer


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myval As Integer
q = TextBox49.Text
r = TextBox50.Text
s = TextBox51.Text
t = TextBox52.Text
If r = s And q <= 5 And r <= 5 And s <= 5 And t <= 5 Then
TableLayoutPanel1.ColumnCount = r
TableLayoutPanel1.RowCount = q
TableLayoutPanel2.RowCount = s
TableLayoutPanel2.ColumnCount = t
Dim i As Integer

c1 = q * r
d = s * t

For i = 1 To c1
Dim mytextbox As New TextBox
mytextbox.Name = "Textbox" & i

mytextbox.Height = TableLayoutPanel1.Height / 6
mytextbox.Width = TableLayoutPanel1.Width / 6
Me.TableLayoutPanel1.Controls.Add(mytextbox)
myval = InputBox("enter val", "value")
myval = Val(mytextbox.Text)


Next
f = c1 + 1
For i = 1 To d
Dim mytextbox As New TextBox
mytextbox.Name = "Textbox" & f
mytextbox.Height = TableLayoutPanel2.Height / 6
mytextbox.Width = TableLayoutPanel2.Width / 6
Me.TableLayoutPanel2.Controls.Add(mytextbox)
f = f + 1
myval = InputBox("enter val", "value")
myval = Val(mytextbox.Text)

Next
Else
MessageBox.Show("you can not exceed 5x5 order/Wrong order", "error", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)
End If

End Sub





Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'result tablelayout panel3

TableLayoutPanel3.ColumnCount = t
TableLayoutPanel3.RowCount = q
g = q * t
h = f + 1
For i = 1 To g
Dim mytextbox As New TextBox
mytextbox.Name = "Textbox" & h

mytextbox.Height = TableLayoutPanel3.Height / 6
mytextbox.Width = TableLayoutPanel3.Width / 6
Me.TableLayoutPanel3.Controls.Add(mytextbox)
h = h + 1

Next





End Sub


End Class
'plz help,...............
 

Latest posts

Back
Top