f



Highlighy text in Text Box

Using an InputBox, there is the option to *suggest* text (Default).  It appears highlighted and can 
be accepted or replaced by the user.  I am attempting to create my own input form which has one Text 
Box, one command button (cmdAccept ) and a simple label to tell the user to make an entry.  What I 
cannot do is to mimic that suggested default input string.  Can someone show me how to do it?

The following code is from a test program with two forms.

'####  this is on FrmMain

Private Sub Option1_Click()

    '   Other Event selected - 14 character maximum
    With FrmBGOther

        .Label1.Caption = "Enter Event name - 14 character maximum"
        .Text1.MaxLength = 14
        .Text1.Text = "Airport"

    End With

    FrmBGOther.Show

End Sub

'####  this is on FrmBGOther

Private Sub CmdAccept_Click()

    FrmMain.Label3 = StrConv(Text1.Text, vbProperCase)
    Text1.Text = ""
    FrmBGOther.Hide

End Sub 


0
7/17/2005 3:00:09 AM
comp.lang.basic.visual.misc 10153 articles. 0 followers. Post Follow

3 Replies
1475 Views

Similar Articles

[PageSpeed] 13

This what you're looking for?

    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    Text1.SetFocus


"Jim Y" <j.s.yablonsky@NOSPAM.att.net> wrote in message
news:ZQjCe.4550$5N3.2631@bgtnsc05-news.ops.worldnet.att.net...
> Using an InputBox, there is the option to *suggest* text (Default).  It
appears highlighted and can
> be accepted or replaced by the user.  I am attempting to create my own
input form which has one Text
> Box, one command button (cmdAccept ) and a simple label to tell the user
to make an entry.  What I
> cannot do is to mimic that suggested default input string.  Can someone
show me how to do it?
>
> The following code is from a test program with two forms.
>
> '####  this is on FrmMain
>
> Private Sub Option1_Click()
>
>     '   Other Event selected - 14 character maximum
>     With FrmBGOther
>
>         .Label1.Caption = "Enter Event name - 14 character maximum"
>         .Text1.MaxLength = 14
>         .Text1.Text = "Airport"
>
>     End With
>
>     FrmBGOther.Show
>
> End Sub
>
> '####  this is on FrmBGOther
>
> Private Sub CmdAccept_Click()
>
>     FrmMain.Label3 = StrConv(Text1.Text, vbProperCase)
>     Text1.Text = ""
>     FrmBGOther.Hide
>
> End Sub
>
>


0
beastfish (245)
7/17/2005 4:38:59 AM
Private Sub Option1_Click()
With FrmBGOther
..Label1.Caption = "Enter Event name - 14 character maximum"
'.Text1.MaxLength = 14'Can be set in properties so line not needed
..Text1.Text = "Airport"
'.Text1.SelStart = 0 'You don't need this line
..Text1.SelLength = Len(.Text1.Text)
'Text1.SetFocus 'Can't do this until FrmBGOther is showing
'So set the TabIndex of .Text1 to 0 in the TextBox Properties
..Show 1' Show the form as a Modal Form
End With


"Jim Y" <j.s.yablonsky@NOSPAM.att.net> wrote in message 
news:ZQjCe.4550$5N3.2631@bgtnsc05-news.ops.worldnet.att.net...
> Using an InputBox, there is the option to *suggest* text (Default).  It 
> appears highlighted and can be accepted or replaced by the user.  I am 
> attempting to create my own input form which has one Text Box, one command 
> button (cmdAccept ) and a simple label to tell the user to make an entry. 
> What I cannot do is to mimic that suggested default input string.  Can 
> someone show me how to do it?
>
> The following code is from a test program with two forms.
>
> '####  this is on FrmMain
>
> Private Sub Option1_Click()
>
>    '   Other Event selected - 14 character maximum
>    With FrmBGOther
>
>        .Label1.Caption = "Enter Event name - 14 character maximum"
>        .Text1.MaxLength = 14
>        .Text1.Text = "Airport"
>
>    End With
>
>    FrmBGOther.Show
>
> End Sub
>
> '####  this is on FrmBGOther
>
> Private Sub CmdAccept_Click()
>
>    FrmMain.Label3 = StrConv(Text1.Text, vbProperCase)
>    Text1.Text = ""
>    FrmBGOther.Hide
>
> End Sub
> 


0
7/17/2005 11:15:06 AM
That did what I wanted it to do.  I plan to use this form multiple times replacing the InputBox. 
FrmBGOther is smaller and can be tailored to suit my conditions.  My primary reason for doing this, 
is control of the length of the input string - MaxLength.  I don't want the user to have to count 
characters.
I have used it (with your help) to replace 3 InputBoxes.
See my code comments below.
Thank you for the help,
Jim Y

"Ivar" <ivar.ekstromer000@ntlworld.com> wrote in message 
news:_4rCe.3403$jo3.3061@newsfe5-win.ntli.net...
> Private Sub Option1_Click()
> With FrmBGOther
=======================

> .Label1.Caption = "Enter Event name - 14 character maximum"
> '.Text1.MaxLength = 14'Can be set in properties so line not needed
These 2 lines change as the form is used in various areas of the main form.
I always thought the InputBox had too long of a TextBox for short input strings.

========================

> .Text1.Text = "Airport"
This line (different text) may/may not be on other form uses

=======================
> '.Text1.SelStart = 0 'You don't need this line
> .Text1.SelLength = Len(.Text1.Text)
=======================

> 'Text1.SetFocus 'Can't do this until FrmBGOther is showing
> 'So set the TabIndex of .Text1 to 0 in the TextBox Properties
> .Show 1' Show the form as a Modal Form
This is something that I have not found in any of my VB6 texts.  I hope
that I can remember it.  I did save your original message - paper and hard drive.

======================
> End With


0
7/17/2005 2:34:31 PM
Reply:

Web resources about - Highlighy text in Text Box - comp.lang.basic.visual.misc

Hands on with Children's book for Windows Phone, an interactive app for kids
I don't have any kids (yet), but if I did I'd be all over Children's books for Windows Phone. It's a free app in the Windows Phone Store for ...

Resources last updated: 3/24/2016 9:53:27 PM