Some questions about VB
I''m using Visual Basic 3 to teach myself, and currently I''m working on a basic web editor, more of a personal-style thing to make it faster to type tags. Anyway, I''m using a text box named txtFile to enter the text, and after clicking a tag button, I have it reset focus to the text box. That puts the cursor at the front of the box--is there any way to automatically move it to the end?
My other question is about the common dialog tool--more specifically, how do I use it? Once upon a time I got the box to come up, but couldn''t get any output (a la return value or something) and couldn''t specify anything for the file type on save and load. Any help?
--
WNDCLASSEX Reality;
...
...
Reality.lpfnWndProc=ComputerGames;
...
...
RegisterClassEx(&Reality);
Unable to register Reality...what''s wrong?
---------
Dan Upton
Lead Designer
WolfHeart Software
WNDCLASSEX Reality;......Reality.lpfnWndProc=ComputerGames;......RegisterClassEx(&Reality);Unable to register Reality...what's wrong?---------Dan Uptonhttp://0to1.orghttp://www20.brinkster.com/draqza
This will send the cursor to the end of the text when
your textbox gets focus. Replace text1 with whatever
your control is called.
Note the braces on sendkeys. End is a reserved word there
are other like home,enter, pgup,pgdn and so on.
Private Sub Text1_GotFocus()
SendKeys "{End}"
End Sub
Have a look here. Gives a tutorial on the common dialog control.
http://www.cit.ac.nz/smac/vb6/pt7_3.htm
your textbox gets focus. Replace text1 with whatever
your control is called.
Note the braces on sendkeys. End is a reserved word there
are other like home,enter, pgup,pgdn and so on.
Private Sub Text1_GotFocus()
SendKeys "{End}"
End Sub
Have a look here. Gives a tutorial on the common dialog control.
http://www.cit.ac.nz/smac/vb6/pt7_3.htm
quote: Original post by ancientcoder
This will send the cursor to the end of the text when
your textbox gets focus. Replace text1 with whatever
your control is called.
Note the braces on sendkeys. End is a reserved word there
are other like home,enter, pgup,pgdn and so on.
Private Sub Text1_GotFocus()
SendKeys "{End}"
End Sub
Have a look here. Gives a tutorial on the common dialog control.
http://www.cit.ac.nz/smac/vb6/pt7_3.htm
First off, I used SendKeys to do something similar before, but the END will only take you to the end of the first line of text if I''m correct, not to the end of the box or end of current line.
He''ll have to copy into a temp variable and concatenate whatever he''s inserting to the end of that variable and then place that into the text box.
Similar to this.
Private Sub cmd1_Click
dim strStuff as string
strStuff = text1.txt
strStuff = strStuff & cmd1.tag
end sub
This will add the contents of the "tag" property of the command button to the END of the current contents. One problem is that it copies to the end. You can look at other properties of the textbox control to determine placement of cursor. I think you could also copy it to clipboard and then paste to textbox and it might put it at the current cursor position. Like I said, haven''t done this in a while.
BeS
It''s Da BOMB Baby!!!
BeSIt's Da BOMB Baby!!!. o O ~ A little nonsense now and then,is relished by the wisest men~ O o .-- Willy Wonka
Um, sendkeys is pretty useless for this situation.
To set focus to the textbox and then set the cursor to the end do this.
txtFile.SetFocus
txtFile.SelStart = Len(txtFile.Text)
to use the common dialog control, lets name it CMD for example.
to load a text file, use this
On Error Goto N:
CMD.Filter = "Text Files (*.txt)|*.txt"
CMD.CancelError = True
CMD.ShowOpen
Open CMD.Filename for input as #1
txtWhatever.Text = Input(LOF(1), 1)
Close #1
N:
to save a file, use this coding..
CMD.Filter = "Text Files (*.txt)|*.txt"
CMD.FileName = ""
CMD.ShowSave
Open CMD.FileName For Output As #1
Print #1, txtWhatever.Text
Close #1
To set focus to the textbox and then set the cursor to the end do this.
txtFile.SetFocus
txtFile.SelStart = Len(txtFile.Text)
to use the common dialog control, lets name it CMD for example.
to load a text file, use this
On Error Goto N:
CMD.Filter = "Text Files (*.txt)|*.txt"
CMD.CancelError = True
CMD.ShowOpen
Open CMD.Filename for input as #1
txtWhatever.Text = Input(LOF(1), 1)
Close #1
N:
to save a file, use this coding..
CMD.Filter = "Text Files (*.txt)|*.txt"
CMD.FileName = ""
CMD.ShowSave
Open CMD.FileName For Output As #1
Print #1, txtWhatever.Text
Close #1
>>Sinful
Um, sendkeys is pretty useless for this situation
<<
If he tabs to it then I gave him the example . I forgot to put
the Ctrl+End in which does the job.
Yes yours is another way of doing it but not the only way.
Private Sub Text1_GotFocus()
SendKeys ("^{end}")
End Sub
Hardly useless
Um, sendkeys is pretty useless for this situation
<<
If he tabs to it then I gave him the example . I forgot to put
the Ctrl+End in which does the job.
Yes yours is another way of doing it but not the only way.
Private Sub Text1_GotFocus()
SendKeys ("^{end}")
End Sub
Hardly useless
thanx...using selstart fixed it, and i got the common dlg control put in and working. I''ll upload v1 to my page in a few hours...
--
WNDCLASSEX Reality;
...
...
Reality.lpfnWndProc=ComputerGames;
...
...
RegisterClassEx(&Reality);
Unable to register Reality...what''s wrong?
---------
Dan Upton
Lead Designer
WolfHeart Software
--
WNDCLASSEX Reality;
...
...
Reality.lpfnWndProc=ComputerGames;
...
...
RegisterClassEx(&Reality);
Unable to register Reality...what''s wrong?
---------
Dan Upton
Lead Designer
WolfHeart Software
WNDCLASSEX Reality;......Reality.lpfnWndProc=ComputerGames;......RegisterClassEx(&Reality);Unable to register Reality...what's wrong?---------Dan Uptonhttp://0to1.orghttp://www20.brinkster.com/draqza
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement