|
-
Aug 21st, 2008, 11:06 AM
#1
Thread Starter
Hyperactive Member
Textbox help
Hi,
well i got a textbox1, and multiline=1.
i cant make this thing work..
when i paste a text into the texbox to make automatically a new line for pasting...and not allowing to press enter...
i m going crazy with this thing...
and...1 more thing...textbox1 on multiline puts the pointer by default at a new line below the last text:
text bla bla bla
bliblibli
blublublu
| | this is where the pointer goes by default
i cant make it go back...i mean i can with sendkeys {backspace}
but i thiunk all would be solved not allowing enter to be pressed nad deleting the last empty line in the textbox..
please any help?
-
Aug 21st, 2008, 11:11 AM
#2
Re: Textbox help
Welcome to the forums. 
To not allow the use of the Enter Key do this
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then KeyAscii = 0
End Sub
Beyond that I don't know what you are trying to do.
-
Aug 21st, 2008, 11:14 AM
#3
Re: Textbox help
Welcome to vbforums
can you explain me some more
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 21st, 2008, 11:16 AM
#4
Thread Starter
Hyperactive Member
Re: Textbox help
thanks 
well...i just want when pasting into a text box a text to put every pasted text in a new line...and after pasting all....(lets say clicking a button) to remove last empy line) and not to permit pressing enter ( i dont know the chr for enter)
-
Aug 21st, 2008, 11:17 AM
#5
Re: Textbox help
 Originally Posted by batori
...textbox1 on multiline puts the pointer by default at a new line below the last text:
text bla bla bla
bliblibli
blublublu
| | this is where the pointer goes by default.....:
Pasting text into a multiline textbox does not put the pointer on a new line, but rather at the end of the last line so there is probably a blank line at the end of the data you are pasting.
-
Aug 21st, 2008, 11:45 AM
#6
Re: Textbox help
You can set the cursor position with the .SelStart and .SelLength properties of the trextbox control. To position it upon a paste operation you will have to subclass the textbox and watch for the WM_PASTE message and then make an additional call to set those properties after the paste operation message.
Code:
'Positions the cursor at the end of the text.
Me.Text1.SelLength = 0
Me.Text1.SelStart = Len(Me.Text1.Text)
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 21st, 2008, 11:58 AM
#7
Thread Starter
Hyperactive Member
Re: Textbox help
that did not work for me 
im trying now to implement pasting + vbcrlf i hope it will work.
after that block the Enter char....
any ideas how to do that?
i know something about visual but not too much
-
Aug 21st, 2008, 12:07 PM
#8
Re: Textbox help
I told you how to block the Enter Key in Post #2 (and that does work)
-
Aug 21st, 2008, 12:10 PM
#9
Thread Starter
Hyperactive Member
Re: Textbox help
ups sorry...i had so many replies i didnt notice xD
ok m8, ill test this soon...ill let u know
-
Aug 21st, 2008, 12:16 PM
#10
Hyperactive Member
Re: Textbox help
If you want to clear out any trailing empty lines, this would do that:
Code:
Do While Right(Text1.Text,2) = vbNewLine
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 2)
Loop
-
Aug 21st, 2008, 12:43 PM
#11
Thread Starter
Hyperactive Member
Re: Textbox help
 Originally Posted by Hack
Welcome to the forums.
To not allow the use of the Enter Key do this
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then KeyAscii = 0
End Sub
Beyond that I don't know what you are trying to do.
that's ok.i would like to put a new line after the pasted text...automatically...i tried with
CODE]Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
KeyAscii = 0
else
text1.text=split(text1.text,vbcrlf)
End If
End Sub[/CODE]
that did not help
now i got a problem that i can delete some lines and let them be empty and i dont want that i prevented that partially with the blocking of Enter...but i still can get emtpy lines between the text lines....
-
Aug 22nd, 2008, 12:08 AM
#12
Thread Starter
Hyperactive Member
Re: Textbox help
 Originally Posted by lone_REBEL
If you want to clear out any trailing empty lines, this would do that:
Code:
Do While Right(Text1.Text,2) = vbNewLine
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 2)
Loop
this is working... 
thanks m8
-
Aug 22nd, 2008, 12:19 AM
#13
Re: Textbox help
Code:
text1.text=split(text1.text,vbcrlf)
Why are you using this for..???
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 22nd, 2008, 12:22 AM
#14
Thread Starter
Hyperactive Member
Re: Textbox help
naah..i dont use it..i tought it will work but i found out later it wont help 
now i got everything set....
now i need to make this thing : when i keypress on text1 i need the text from clipboard and paste it in ( i know how to do that), but, after the paste i need a vbnewline automatically...i tried that with this
Code:
Text1.Text=Text1.text + vbnewline
but this brings me to the first line and when i write i get the words in backward mode LOL
-
Aug 22nd, 2008, 12:31 AM
#15
Re: Textbox help
use like this:
Code:
Text1.SelStart = Len(Text1.Text)
Text1.Text = Text1.Text & vbNewLine
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 22nd, 2008, 12:35 AM
#16
Thread Starter
Hyperactive Member
Re: Textbox help
 Originally Posted by akhileshbc
use like this:
Code:
Text1.SelStart = Len(Text1.Text)
Text1.Text = Text1.Text & vbNewLine
not working as i tought...
well it keeps making new lines but i get the pointer at position 0, and when i type i get the words in backwards in the first line only...
i would need that when i paste the text, to go directly to a new line into i will paste again some text,and then again a new line automatically where ill put again pasted text....and so on...
-
Aug 22nd, 2008, 12:50 AM
#17
Re: Textbox help
what code do you have so far.????
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 22nd, 2008, 12:54 AM
#18
Thread Starter
Hyperactive Member
Re: Textbox help
i have many code...but i dont have any good code for this small operation...it seems complicated for that...
ex:
you staart with a blank textbox,you dont permit entering Enter, and everytime you paste a text CTRL+V your text is pasated on the first line and the pointer goeas automatically on the second line waiting for the next paste command...and them you paste again and the pointer goes automatically on the third line..i cant achieve that 
i tried the code i got here and the one i wrote..but they just kept making empty lines (which can be hanled by the code given up) but the problem is that everytime i write or paste my text goes in the first line
-
Aug 22nd, 2008, 01:07 AM
#19
Re: Textbox help
Something like this...????
Code:
Private Sub Text1_Change()
Text1.SelStart = Len(Text1.Text)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then KeyAscii = 0
Text1.Text = Text1.Text & vbNewLine
End Sub
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 22nd, 2008, 10:11 AM
#20
Thread Starter
Hyperactive Member
Re: Textbox help
thats nice but...
i cant delete any line and when i paste in the first line the first line becomes empty...and the pasted textz goes to second line...
-
Aug 22nd, 2008, 10:48 AM
#21
Re: Textbox help
Oho, you want to replace each line when you paste. Is that so...?
I will work on it and will soon reply(tomorrow), 'cause I am now on a trip to my homeland
c u 2morrow
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 22nd, 2008, 12:04 PM
#22
Re: Textbox help
What is in this text box anyway?
I've never heard of anyone wanting to do the things to text in a textbox that you are doing.
-
Aug 23rd, 2008, 01:25 AM
#23
Re: Textbox help
After some experiments, I came up with this code...
I don't have any idea... The below one will select the first line in a multiline textbox, when it gots the focus...
I think others have good solutions than this...
-Best wishes
Code:
Private Sub Text1_GotFocus()
Text1.SelStart = 0
Text1.SelLength = InStr(1, Text1.Text, vbNewLine)
End Sub
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 23rd, 2008, 02:43 AM
#24
Thread Starter
Hyperactive Member
Re: Textbox help
ill try that now m8... 
@Hack
well of course, i have strange idea coming to my mind
-
Aug 23rd, 2008, 02:47 AM
#25
Thread Starter
Hyperactive Member
Re: Textbox help
edit
nope m8, i tried the last code and it seems to do nothing much...
but,this code seems to be very useful, just when i paste in the first line i get the pasted text in the second line,that's the problem...
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then KeyAscii = 0
Text1.Text = Text1.Text & vbNewLine
End Sub
-
Aug 23rd, 2008, 04:44 AM
#26
Re: Textbox help
If we are able to find the cursor position, then it will be some more easy to solve the problem....
@@@@To other members:
Does anybody know how to find the position of the cursor in a textbox..???
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 23rd, 2008, 08:10 AM
#27
Re: Textbox help
 Originally Posted by akhileshbc
If we are able to find the cursor position, then it will be some more easy to solve the problem....
@@@@ To other members:
Does anybody know how to find the position of the cursor in a textbox..???
The cursor position is what you already knew and used: Text1.SelStart
but you set it to a new value (Text1.SelStart = n) instead of read it (n = Text1.SelStart)
-
Aug 23rd, 2008, 10:02 AM
#28
Thread Starter
Hyperactive Member
Re: Textbox help
this code seems to be easy but insted it's quite tricky xD
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|