how can i write a code for this
select all
ctrl+right shift
in a richtextbox
is it possible?
:confused:
Printable View
how can i write a code for this
select all
ctrl+right shift
in a richtextbox
is it possible?
:confused:
VB Code:
Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer) ShiftTest = Shift And 7 If ShiftTest = 3 Then RichTextBox1.SelStart = 0 RichTextBox1.SelLength = Len(RichTextBox1.Text) RichTextBox1.SetFocus End If End Sub
What is "ShiftTest"?Quote:
Originally Posted by ganeshmoorthy
Im sorry, dint include the declaration part, here is the full codeVB Code:
Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer) Dim ShiftTest As Integer ShiftTest = Shift And 7 If ShiftTest = 3 Then RichTextBox1.SelStart = 0 RichTextBox1.SelLength = Len(RichTextBox1.Text) RichTextBox1.SetFocus End If End Sub
:(
this code can applyed for mouse down and i need it in form load
also i need it to be active without pressing any key in keyboard or mouse
how?
Yes, It can be applied to your Keyboard or Mouse Down events.Quote:
Originally Posted by om-yousif
??????????Quote:
Originally Posted by om-yousif
Or:But why every second time GotFocus the text turn to UPPERCASE?VB Code:
Private Sub RichTextBox1_GotFocus() SendKeys "^+a" End Sub
OK ganeshmoorthy
let me tell you what i need
i have a richtextbox includes an Arabic Text
this text will be loaded in Form_Load()
what i need is to change the Alignment of the richtext to right automatically
without pressing anything in keyboard or mouse
these two steps in pressing the keyboard will do this
select all
ctrl+right shift
but i need to convert it to a code in VB so the text's alignment will be changed just when form loaded
You can use the keybd_event() API function. Are you sure pressing CTRL+Right Shift aligns the text to the right? It's not working for me.
VB Code:
Option Explicit Private Const VK_SHIFT = &H10 Private Const VK_CONTROL = &H11 Private Const VK_RSHIFT = &HA1 Private Const VK_A As Integer = 65 Private Const KEYEVENTF_EXTENDEDKEY = &H1 Private Const KEYEVENTF_KEYUP = &H2 Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, _ ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Private intActivate As Integer Private Sub Form_Activate() If intActivate = 0 Then 'Press down control key. keybd_event VK_CONTROL, 0, 0, 0 'Press right shift. keybd_event VK_RSHIFT, 0, 0, 0 'Release right shift key. keybd_event VK_RSHIFT, 0, KEYEVENTF_KEYUP, 0 'Release control key. keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 intActivate = 1 End If End Sub Private Sub Form_Load() rtb.SelText = "fjdslkfkj" & vbNewLine & "jflksdfjslkjfd" & vbNewLine & "fjlsdfj" 'select all 'ctrl+right shift With rtb .SelStart = 0 .SelLength = Len(.Text) End With End Sub
yes DigiRev
(Ctrl+right shift) will do it
Quote:
Originally Posted by om-yousif
??VB Code:
Private Sub Form_Load() With RichTextBox1 .SelStart = 0 .SelLength = Len (.Text) .SelAlignment = 1 End With End Sub
thanks for all
and special thanks for gavio :)