VB 6.0 - Text Box doesn't like "Enter"

Asked By Joe Lewis
03-Feb-12 07:05 PM
I have a text box on one form, and I copied that text box to another form, and did that an additional 3 times.   So I now have four text boxes on that other form.   The text box on the first form works fine, and I can type in a value and hit <Enter>, and everything is great.   But with the four new text boxes on the 2nd form, I can type in numbers and hit Tab, to move focus somewhere else.  And everything is fine.  But if I hit <Enter> after typing the values in the box, the whole program freezes, the cursor disappears, and within a few seconds the hourglass appears.   And the only solution is to shut down the program at that point.  I guess I may be "reading" the value of the text boxes a bit differently between the two forms (I need to check on that).  I had trouble with my new text boxes when I just put a VariableName = TextBoxName.Text command within the textbox click (or change) procedure.  So I ended up only assigning the variables (from the text box values) in a separate command button procedure.   Could that have something to do with why hitting <Enter> throws everything into chaos?   BTW, I checked ALL the properties of the four new text boxes against the original counterpart in the first form.  They are all the same!   Any help would be greatly appreciated!
  Danasegarane Arunachalam replied to Joe Lewis
03-Feb-12 08:42 PM
Do you have any code in the keydown event of the form . Normally setting the Keypreview=true and pressing the enter button cause the keydown or keypress event of the form/textbox. You say you copied the fourth textbox from the previous form. Did you check the Textbox4 keypress event for any coding ?
  Joe Lewis replied to Danasegarane Arunachalam
03-Feb-12 10:39 PM
Actually, I copied all four text boxes from the original (on another form).  But none of my text boxes have much code at all.  And no "keydown event" code for sure.  The only code for my four new boxes shows up in the Click event of a command button on the same form.   And that just assigns 4 variables the corresponding values in the four text boxes.  But again, during runtime, I can type in the values and hit tab or something else, and everything works fine.  But I cannot hit <Enter> in any of the four boxes (after typing the value), or the hourglass comes up and I have to shutdown VB.  Thank you for your response.
  Amit Choudhary replied to Joe Lewis
03-Feb-12 11:01 PM
See if you have defined any button for process on property "Accept Button"
System will automatically click that button on Enter of any control on form.
It might be possible that VB is calling that procedure.
  Anoop S replied to Joe Lewis
04-Feb-12 03:38 AM
can you upload your code?
or
do one thing, use Step Into option in vb (when you press F8, Visual Basic run your code, goes to the very first statement ,which is indicated by the arrow and the highlighting  and then stops and waits for more instructions. ) , press f8 key, using this you can analyze your program line by line and so that you can find which line causing freezing problem
  Reena Jain replied to Joe Lewis
04-Feb-12 05:54 AM
Hi,

Handle the keyascii for each text box. In each textbox control put below code in the Keypress event

If KeyAscii=13 Then
sendkeys "{tab}"
End If


it is works for me
  Joe Lewis replied to Reena Jain
04-Feb-12 12:01 PM
Thanks Reena.   So this should effectively make the "enter" key (for that text box) behave just like the Tab key (which I already know works), right?  If that works, that will be very simple obviously.   I will try it.
  Joe Lewis replied to Amit Choudhary
04-Feb-12 12:06 PM
That sounds interesting, but I cannot find any property (on the form or the controls) called "Accept Button".   Where do I look for this?   Thank you.
  Joe Lewis replied to Anoop S
04-Feb-12 12:08 PM
Thanks!  But once I am into Debug Mode, how do I duplicate the hitting of the Enter key?   I can't see how this could work.
  Joe Lewis replied to Reena Jain
04-Feb-12 12:24 PM
Okay, I tried your advice, and it didn't work.   However, I learned more stuff.  When I hit Enter in any of those 4 text boxes, the cursor essentially disappears.  But, it is still visible on the desktop or exterior icons of Windows.  But when I try to move the cursor back onto my program windows/forms, it goes behind them (i.e. becomes invisible).   The only option is still just to shut down the VB program.  I just thought that is another important clue I should throw out there.   Thanks again.
  Joe Lewis replied to Joe Lewis
04-Feb-12 12:51 PM
Okay, I decided to just delete the four little text boxes, and create them from scratch, with the same names.   Well, I can't believe it, but I'm having the same problem!  Even with brand new text boxes that I created in the form with the toolbox (as opposed to copying other text boxes from another form!).   But one more piece of information.  When I type a value (like 1201, etc) into the text box and hit "Enter", the caret doesn't disappear, and I can move it around, but I cannot pick anything.  And as I said before, the cursor is only visible when it is outside the boundary of any VB windows.  So I've got this caret (I-beam) that I can move around, but it is useless.  I can't type anything else anywhere!   And all of this happens only because I hit "Enter" in a text box!   If I hit Tab, or simply click into another text box, everything works fine!   Please help.   This is worse than I thought.   Thank you.
  Anoop S replied to Joe Lewis
05-Feb-12 10:50 AM
can you upload your program here, just zip the file and use upload manager( 1st option in menu)
  Anoop S replied to Joe Lewis
05-Feb-12 10:55 AM
are you using any validation on enter key? if its there remove that and check, You will need to post the relevent code/attach the project before anyone can guess what happens in your code
  Somesh Yadav replied to Joe Lewis
06-Feb-12 07:43 AM
HI , your problem will be solved by doing the below one,
Handle the keyascii for each text box. In each textbox control put below code in the Keypress event
If KeyAscii=13 Then
SendKeys"{tab}"
End If
It is working for me



I
  Somesh Yadav replied to Somesh Yadav
06-Feb-12 07:44 AM
HI , your problem will be solved by doing the below one,
Handle the keyascii for each text box. In each textbox control put below code in the Keypress event
If KeyAscii=13 Then
SendKeys"{tab}"
End If
It is working for me
Create New Account
help
search from gridview using textbox in vb.net dear sir i have a database table with column name "name, state, contact no, age and id" i want when i press enter or type character in textbox of then open a gridview and i search a data in name column with typing character in textbox then only match character appear on gridview and i select one row and press enter then the all field of that row appear on own field textbox like name in name textbox age in age textbox and gridview will close auto. i need your help on above case urgent, so please any text before or after the search expression. Step 3: Add a Search Box This bit is easy, just create a textbox that you call txtSearch - this is what is referenced
How to add a dynamic textbox with MultiLine??? HElP!!!! C++ / VB Hi, I need to create a dynamic textbox with MultiLine set to True & ScrollBar set to Vertical. I have tried to code as below, dim objControl as Control Set objcontrol = Controls.Add("VB.textbox", sName) With objcontrol 'objcontrol .Move iLeft, iTop, iWidth, 100 .MultiLine = True .ScrollBars = 2 .Visible = True a read-only property for MultiLine & ScrollBars. Anyway that I can program to make the textbox as MultiLine & Scrollable when textbox is created dynamically? Regards Vanessa VB Controls Discussions MultiLine (1) Textbox (1) TB (1) MSFTNGP (1) TK (1) ScrollBars (1) ObjControl
user32.dll function fails without any error. I am afraid it kills my business. C++ / VB Hello! I have a code that relies on the user32.dll. It uses the SendInput if it don't find the error. What would you do to find the error? VB WinAPI Discussions Windows XP (1) Virtual PC (1) Windows Update (1) Windows Vista (1) IsDEREFER always in a 'double pack'? First of all you should differentiate in your code between VB and Windows API errors. The line On Error Goto ErrHandler only catches VB errors, not Windows API errors. To implement the latter you should change your code: l Beside this: MsgBox "An error occured in function #392347" is not very useful if a VB error occurs. MsgBox "Error " & Err.Number & " occured in function #392347" is mutch better! In general very hard to tell something about the reasons if we don't know what your VB program exactly does. The given code snippet doesn't provide any information about this! - Did log file in the user's TEMP folder: http: / / groups.google.com / group / microsoft.public.vb.general.discussion / msg / df0e43d1c26176ea Ralph suggestion to use DebugView is a good suggestion. You use We can assume that it is really a problem with the SendInput function because the VB's sendkeys method works. Any more ideas? OS: 5.1. SP: Service Pack 2 I
AddHandler in C# doesn't work .NET Framework With ASP.NET 2.0: In VB code I have added controls dynamically, then added a handler using AddHandler(Object, Method) It EumdnUiAzorUcbnaRVnzvQA (1) ControlToAddTo.EventToHandle (1) System.ComponentModel (1) EventHandler (1) EventArgs (1) ASP.NET (1) TextBox (1) VB (1) Google is your friend: http: / / www.google.co.uk / search?sourceid = navclient&hl = en light beeing lit. Bjorn Hi Bjorn, In C# we use + = operator to attach event handlers: TextBox textBox = new TextBox(); textBox.ID = "txt1"; textBox.Text = "Howdy"; textBox.AutoPostBack = true; tetxBox.TextChanged + = new EventHandler(this.TextChangedHandler); private void TextChangedHandler(object
thru WinForm Controls .NET Framework Hi All What is the code to loop thru all textbox controls on a form? TIA johnb VB.NET Discussions TextBox (1) VB (1) Control (1) OP (1) GuysThank (1) GetType (1) WinForm (1) Corrected.Thanks (1) The has a GetType() method to allow you to determine if the current control is a TextBox. http: / / msdn.microsoft.com / en-us / library / system.object.gettype(v = VS.90).aspx Am is shorter ;-) ): 'assuming option infer on for each c in controls if typeof c is textbox then with directcast(c, textbox) .property = value end with end if next - - Armin Peter, I have seen that the getType here in this newsgroup has done it forever. If Typeof object Is Classname? http: / / www.vb-tips.com / ControlBorder.aspx Is this a kind of verCSharping (I do not know if