|
I didn't give you the code, but the same textChanged event can be assigned to all of your 100 textboxes. So I would suggest that you connect each of your textboxes with that one textChanged event.
The way to do this is:
At the end where you see the Handles key word you have the TextBox1.TextChanged
All you have to do is add:
,TextBox2.TextChanged, TextBox3.TextChanged, ... till you have added all 100 textboxes.
Hope that helps.
Ben
|
|
|
|
|
u want tosay like this....
Private Sub Textbox1_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
what about the other places where textbox1.text is written like textbox1.keypress and if val(textbox1.text) and all such place where only textbox1.validated....
its highly confusing...
Private Sub Textbox1_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
If Val(TextBox1.Text) > 45 Then TextBox1.Text = CStr(0) : MsgBox("Please Enter A Number Between 0 to 45", MsgBoxStyle.Critical)
End Sub
Private Sub Text1box_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
Select Case KeyAscii
Case 48 To 57 '0 To 9
Case 8 'Back Space
Case 13 'Enter
Case Else 'Other Keys
KeyAscii = 0
End Select
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
End Sub
|
|
|
|
|
Your eventSender is the TextBox
So:
if Val(CType(eventSender, TextBox).Text) > 45 Then CType(eventSender, TextBox).Text = CStr(0) ...
Hope that helps.
Ben
|
|
|
|
|
thanks man..
its working perfectly...
and reduced mah problem alot..
regards..
manni
|
|
|
|
|
I think as a user I would be annoyed if I got a message everytime I typed in a number greater then 45. The way you have it set up I could type in 12 then accidentally hit 3, thus having 123 in the box, and I would get a warning in addition to the value being reset to 0. I think you should just stop the key from being pressed if it will result in to large a value. This way the user can't type in a larger number and you avoid the warning and clearing the value simply because I hit an extra character on my keyboard. Here is the code to handle that.
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Char.IsDigit(e.KeyChar) Then
'Key was a digit
Dim txtBox As TextBox = DirectCast(sender, TextBox)
Dim value As Integer
Dim newText As String = txtBox.Text.Remove(txtBox.SelectionStart, txtBox.SelectionLength)
newText = newText.Insert(txtBox.SelectionStart, e.KeyChar.ToString)
'If value of textbox will be greater then 45 ignore key
If Integer.TryParse(newText, value) Then
If value > 45 Then e.Handled = True
End If
ElseIf Not Char.IsControl(e.KeyChar) Then
'Ignore key: It wasn't digit, backspace, enter, or delete
e.Handled = True
End If
End Sub
|
|
|
|
|
Oh, one more thing. The function 'val' returns 0 if the string isn't a number. Remember a user can still copy and paste text into your textbox. If you use val to determine the value a string of letters it will pass because 'val' will return 0 which is less then 45. You should first make sure the text is a number then convert it's value.
|
|
|
|
|
use the control collection and add an event to each textbox calling the same routine
|
|
|
|
|
Hi
You Can Make An "User Control" For Problem Such This. or If Posible You Can Use Array. If You Make Array TextBox Your Code Will Be Same This :
Private Sub Text1_Change(Index As Integer)
If Val(Text1(Index).Text) > 45 Then Text1(Index).Text = 45: MsgBox "Please Enter A Number Between 0 to 45", vbCritical
End Sub
Private Sub Text1_KeyPrees(Index as integer,KeyAscii as integer)
Same Last Code
End Sub
|
|
|
|
|
Hi,
I have an existing VB.Net application which loads selected Crystal XI reports and passes parameter values to the report from controls on the User's GUI. The code looks at the properties of each parameter field and determines its type, current values, default values etc and presents the appropriate interface to the user for parameter input. I am having trouble accessing or even identifying dynamic parameter lists which I want to refresh and present to the user for selection in a ComboBox or similar. I have several static lists which work fine. Is this a version issue? Are Dynamic ( and cascading ) parameters supported in .NET?
Nas
|
|
|
|
|
Hi all, I started learning VB.NET a few months ago and I love it.
What I'm having trouble with though is that I'm trying to assign a picturebox to a listbox so that the picture changes when selecting another item. But I can't figure out how. The pictures are in the project resource files, how do I assign them to the process? There's 78 pictures.
The form with the picturebox and listbox.[^]
Cheers!
|
|
|
|
|
Is your question about extracting the resources or assigning them to the picturebox
|
|
|
|
|
First, it depens on how you want to use resources. Are these embeded pictures as resources in your project or you are going to load them from references or from a specific directory.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Well what I want to do is; When the user selects an item in the ListBox, the PictureBox loads a file from the resources and displays it, and when the user selects another item, the PictureBox do the same procedure but gets another picture.
Since I've never used code to grab something from the resources, I have no clue on where and how I'm gonna load them. A friend of mine gave me this[^] link where it was described how a PictureBox could be used.
pictureBox1.Image = _<br />
new Bitmap(Assembly.GetExecutingAssembly(). _<br />
GetManifestResourceStream("PictureBoxControl.tinyemulator_res.jpg"))
The issue with this is that first Assembly is undefined and second that, well I have no freakin' idea on where the UI input should be. Is that enough to help me?
Cheers!
|
|
|
|
|
First do you have Imports System.Reflection at the beginning of your code, you need that to access the Assembly object. For the next part use the ListBox SelectedIndexChanged event, use the selecteditem value to index your resource file.
Hope that helps
|
|
|
|
|
Please check this link out http://msmvps.com/blogs/JayHarlow/default.aspx[^] It can give you an idea. If I were you, I would use embeded resources of course it is much easier to deal.
Also here is another approach:
<code>
The following example uses the ResourceManager.GetObject method to retrieve and display a binary resource (such as a graphic image).
…
Dim private rm As ResourceManager
rm = New ResourceManager("MyImages", Me.GetType().Assembly)
PictureBox.Image = Ctype(rm.GetObject("MyObject"), System.Drawing.Image)
…
</code>
-- modified at 16:24 Monday 12th March, 2007
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
im creating a form where users can login to a seperate form using a login name and password. I'm trying to compare the users imput for the login to a feild in MS Access and the same with password input in a seperate feild in the same table(PCBank.mdb). if input is correct go to form2.
if anyone can help it would be greatly appreciated. code below is my attempt
Imports System.Data.OleDb
Public Class Form1
Dim conn As OleDbConnection
Dim comm As OleDbCommand
Dim dr As OleDbDataReader
Dim da As OleDbDataAdapter
Private Sub connect()
conn = New OleDbConnection
conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=|datadirectory|\PCBank.mdb"
conn.Open()
comm = New OleDbCommand
comm.Connection = conn
comm.CommandType = CommandType.Text
End Sub
Private Sub DisplayRecord()
Me.txtid.Text = dr.GetString(0)
Me.txtpass.Text = dr.GetString(1)
End Sub
Private Sub btnlogin_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
connect()
comm.CommandText = "select * from Managers where id like '" & txtid.Text & txtpass.Text & "%'"
If txtid.Text = "Managers" = dr.GetString(0) And txtpass.Text = "Managers" = dr.GetString(1) Then
My.Forms.Form2.Show()
Me.Close()
End If
End Sub
End Class
|
|
|
|
|
peteyshrew wrote: Dim conn As OleDbConnection
Dim comm As OleDbCommand
Dim dr As OleDbDataReader
Dim da As OleDbDataAdapter
Why would you make these members ?
peteyshrew wrote: comm.CommandText = "select * from Managers where id like '" & txtid.Text & txtpass.Text & "%'"
You're truncating the username and password in to one string and using LIKE. What you should be doing is doing a select that checks if a record exists with exactly the username and password that were entered, so the real username and password never get pulled out of the database.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have have not look at this in detail but does not msaccess require you use "*" as a wild card instead of the SQL "%"/
jhoga
|
|
|
|
|
I have hierarchical data that the user can make one of four choices about. The primary treeview manages @900 rows of data that collapsed to @100 groups.
I need to draw a tree view with a 'radio button group' where the radio buttons are related to the treeview node index.
I have made a User Control for the 4 radio button but can't quite figure out:
1) How to Position the radiobuttons to align with the tree view node
2) Linkage to connect the button data to the treeview node
i.e.
[a,b,c,d] tvNode1
[a,b,c,d] tvNode2
Each control is located on separate panels, panel 1 is for the radio buttons, panel 2 is for the Treeview. - Is there may be a better way???
TIA
Tom Hamilton
Sacramento, CA
|
|
|
|
|
I would start from an existing treeview control and set the the DrawMode-property to OwnerDrawAll, so you you don't have to bother about the complexicity of the positions. In this mode you can draw your buttons instead of the existing signs in the treeview. Does this help your problem?
|
|
|
|
|
In vb.net 2005.
I am wanting to say at form load that if a global value (strName) has not been used (i.e. has not been entered into), then load another form, how can i do this, i have tried:
If strName.length < 1
strName.Empty
Help!!!
|
|
|
|
|
better delete this one...you'll get yelled at for double posting
|
|
|
|
|
try this Code
If strName= Nothing Then
else
End If
|
|
|
|
|
Sorted now cheers
|
|
|
|
|
In vb.net 2005.
I am wanting to say at form load that if a global value (strName) has not been used (i.e. has not been entered into), then load another form, how can i do this, i have tried:
If strName.length < 1
strName.Empty
Help!!!
|
|
|
|