|
1. Count the number of CRs in the textbox.text and beat on the user if there is more than 1
2. Use the keydown/up events to interactively manage the characters typed into the textbox.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks. I was getting to that I just was wondering if perhaps there was a setting I had missed.
This points me in the right direction.
If the beatings worked I wouldn't need to do this. LOL
Judy
|
|
|
|
|
Ok, I've counted the number of returns in the box and can display a message but if I tell it to supress the keystroke in the keydown event it still enters the return in the box.
How do I stop the return from being entered?
Thanks,
Judy
|
|
|
|
|
Never mind. I quit displaying the message explaining that they couldn't add anymore lines and then the key supression started working.
Thanks for all your help,
Judy
|
|
|
|
|
Try the keyup and test, keydown happens BEFORE the key is entered.
I don't think you can actually suppress the enter key from being pressed. I have always found interactive management of what the user does to be painful, I almost always let them do what they want and then clean up after, probably using the on leave event.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Actually it is suppressing the keystroke on the keydown event. I created a derived class and added the count returns as a property and put the keydown event code override in the class and it works well. I also added an event for the text change to keep track of whether or not they go in and delete text and/or a return so that the count will remain accurate while they are working in the text box.
Private Sub MyTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If (e.KeyCode = Keys.Enter Or e.KeyCode = Keys.Return) Then
If Me.CRLFCnt > 0 Then
e.SuppressKeyPress = True
Else
Me.CRLFCnt += 1
End If
End If
End Sub
As I said it took me awhile to figure it out and I had a message box popping up to tell them they had tried to put in too many lines and for some reason that caused the suppress method not to work. I tried putting the message box in the keyup event but then it just looped if you hit return on the 'OK' button. If you clicked it with the mouse it went away but we try to code things so the users don't have to take their hands from the keyboard any more than possible.
Thanks for your help it did point me in the right direction and saved me a lot of time.
Judy
|
|
|
|
|
My pleasure. I see you have run into the modern developers curse, if you hold your tongue just right and face into the wind, it works. Now you can understand why I hate interacting with the textbox events.
Well done.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
Does anyone know of functions that may be accessed via VB code that locate the mouse in a given location, then create a mouse click event.
The idea is to control an external application by locating the mouse over a button on that application then producing the click event within that application.
I know of the "SendKey" and "SetForegroundWindow" functions, but the external application doesn't have a hot key assigned to the commands I'm trying to access.
Thanks,
Andy
|
|
|
|
|
How to findout the total number of elements stored in array
i created array of string and storing employee name into it from database . how i come to know that how many times employee name repeates in an array
like this
For i = start_cell_number To end_cell_number
Dim testarray(48) as string
testarray(i) = (dr("User_Name").ToString())
Next
how i calculate total number of repetition of user name inside array?
any suggestion or link is highly appercited .
Regards
Rameez
|
|
|
|
|
use
testarray.Length
to find total no of elements stored in array
|
|
|
|
|
rameez Raja wrote: How to findout the total number of elements stored in array
testarray.length
rameez Raja wrote: i created array of string and storing employee name into it from database . how i come to know that how many times employee name repeates in an array
Declare an integer variable and increment its count every time you find the desired employee with in the loop
|
|
|
|
|
thanks for reply,
Actullay i have to findout total number of repetition of string inside array.
for each employee name i have to find out repitation of string name inside array .
i have tried like this
Dim icount As Integer = -1
Do
icount = Array.IndexOf(testarray, Label1.Text, icount + 1)
Response.Write(icount.ToString() + "<br>")
Loop Until icount = Array.LastIndexOf(testarray, Label1.Text)
label1.text contains name of employee am i on right track please suggest me ?
how i calculated the total number of repitation of string in array?
give me hint or link .
Regards
Rameez
|
|
|
|
|
|
|
jalandoonkNEWBIE wrote: I have this web application
And yet you didn't ask in the ASP.NET forum.....
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
yeah, sorry. if you can answer my question id appreciate it
|
|
|
|
|
Hi, I'm trying to dynamically build an insert query.
Dim strIns as string = "Insert into XXXX (Field01, Field02) values( '{0}', {1})"
Dim strVals as string = ""Value00","value01""
Dim strWork as string = String.Format(strIns,strVals)
This results in an error
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
Could anyone please point me into the right direction?
Thanks
|
|
|
|
|
{0}, {1} means you need to pass two arguments besides strIns
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Thanks Christian,
The arguments are supposed to be in the strVals that is being passed.
From your reply I gather that I need to pass the individual arguments rather than building a string with the values to pass.
regards,
|
|
|
|
|
Correct.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Somebody can tell me( teach me ) how can i program an editable listview?
I want to hve a listview that can be editable in any subitem.
Now i can only edit the item...
the code to edit the item is...
Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
Me.ListView1.LabelEdit() = True
Me.ListView1.SelectedItems(0).BeginEdit()
End Sub
Please i need help...
By the way my english is bad (I speak portuguese ) so forgive me if made a mistake ...
thanks
Just learning
|
|
|
|
|
ROC_Jnr wrote: Me.ListView1.SelectedItems(0).BeginEdit()
Me.ListView1.SelectedItems(0).SubItems(1).BeginEdit()
I think, I NEVER (amlost) allow inline editing in grid or listviews. I make the user double click to open a form to CRUD a record, that way you are only managing 1 record at a time.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
What do you mean by CRUD?
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
clickety[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Nice acronym
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|