2 problems with vb 
Author Message
 2 problems with vb

I have had 2 problems with vb6 running on XP Pro where the
way the program works and the on-line docs differ.
1. Richtextbox - says you can change the color of the font
and if you don't have any of the text selected, it will
change from that point only.  On my system it changes all
the text in the textbox even if there is no selected text.

2. Form_keypress event - The docs say I can capture the
enter key if I set keypreview = true.
The keypress event does not capture the enter key.
It will capture other keys.
Any help very much appreciated.
Thanks.
Kay Davenport



Sat, 07 Aug 2004 06:22:52 GMT  
 2 problems with vb

Quote:
> I have had 2 problems with vb6 running on XP Pro where the
> way the program works and the on-line docs differ.
> 1. Richtextbox - says you can change the color of the font
> and if you don't have any of the text selected, it will
> change from that point only.  On my system it changes all
> the text in the textbox even if there is no selected text.

I've not used the RichTextbox under XP, so I can't help there, but using
simply
    RichTextBox1.SelColor = vbRed
just worked for me in Windows 2k
Perhaps you could post some code that exhibits the problem?

Quote:
> 2. Form_keypress event - The docs say I can capture the
> enter key if I set keypreview = true.
> The keypress event does not capture the enter key.
> It will capture other keys.

Do you have a default button (ie a button with it's Default property set to
True)?
If so, I believe this will receive the keypress first, and so you will need
to have the default property set to False

--
Chris Anderson
(aka Merak on VISBAS-L)



Sat, 07 Aug 2004 06:33:21 GMT  
 2 problems with vb

Quote:

> >Thanks for your reply Chris.
> Problem 2.
>  The default property is set to false on the command
> buttons.
> I ran another test with a blank form first and the key
> press event (which worked on the enter key) - then I added
> one command button with the default property set to false
> and the keypress captured other keys but not the enter key.

hmm..yeah that happens on Win2k as well (so it's not an XP thing)
It's probably because the button has focus because if you add a textbox and
give it focus, the form then receives the keypress
Now you know the actual problem, I hope you can see a way of fixing it in
your app (either call the routine that you call in your Keypress event from
within the click event, or perhaps replace the buttons with another control
that does the same job without the above problem - an option button with
it's style set to graphical, and the following code in it's click event:
    Private Sub Check1_Click()
       Check1.Value = vbUnchecked
    End Sub
..bit of a hack, but it works :-) )

Quote:
> Problem 1.
> Selcolor doesn't work for me on my system.  Perhaps I am
> doing something wrong. I am sending you a zip file
> including the form and the exe and a display of the
> richtextbox results on that selcolor problem.  Maybe I am
> suppose to be referencing the textrtf rather than text. If
> you have time to look at it, I would very appreciate.

Ahh..The problem is that you are looking at it as a standard TextBox, and
adding the extra text using the Text property
SelColor will set the colour for subsequently typed text, or text added
usingthe SelText method

In your example, instead of using
     RichTextBox1.Text = RichTextBox1.Text & vbCrLf & "This is the next
line"

try using
     RichTextBox1.SelText = "This is the next line" & vbCrLf

--
Chris Anderson
(aka Merak on VISBAS-L)



Sun, 08 Aug 2004 08:14:48 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Instalation Problem + Class problem (automation) (VB+Access)

2. Drop and Drag Problem and Deployment Problem in VB 50 Enterprise

3. Problems with VB and VB/Link

4. Multilink/VB 2.0 problems in VB 4.0/Win95

5. Date Problems with VB 4 16 bit and VB 6

6. Problem with VB 5.0 apps after VB 6.0 install

7. Are there problems running VB 4 and VB 5 apps on same machine

8. VB 5.0 ...Licensing problem with VB Application Wizard...Anybody Else

9. Problem loading VB Com in VB Script

10. Email problem through VB

11. Database problems in VB 6.0

12. Problem with VB to refer a subform.

 

 
Powered by phpBB® Forum Software