|
-
Mar 9th, 2007, 10:05 AM
#1
Thread Starter
Member
List Box Problem
Hai,
I Am Doing A Project In VB 6.0 IN Which I AM USING A RICH TEXT BOX TheN I HAVE TO DISPLAY A Listbox WITH LIST ITEMS IN IT At The Cursor Position When Ever A Space Is Encounterd
Can Any One Suggest
Last edited by RAKESHTATI; Mar 9th, 2007 at 10:18 AM.
Reason: NOT COVERED ALL ISSUES
-
Mar 9th, 2007, 10:09 AM
#2
Re: List Box Problem
Where the space will be encountered?
Please mark you thread resolved using the Thread Tools as shown
-
Mar 9th, 2007, 10:11 AM
#3
Re: List Box Problem
Sort of intellisense I might guess.
-
Mar 9th, 2007, 10:25 AM
#4
Re: List Box Problem
I'm not sure this will work, but here's some "pseudocode". Write a looping routine using INSTR to locate blanks in the .Text string property of the rich text box. When found, initialize an array pointer equal to the value returned by INSTR as it moves along the .Text string.
Count the number of blank hits. When INSTR returns a zero, no blanks are left. Now add all the values you found in the array that you counted to the list box to display them.
-
Mar 9th, 2007, 10:30 AM
#5
Thread Starter
Member
Re: List Box Problem
I Didn't Understand It Clearly Can U Explain It Clearly
-
Mar 9th, 2007, 10:31 AM
#6
Re: List Box Problem
Read up on InStr() function so you'll understand what it is for.
-
Mar 9th, 2007, 10:38 AM
#7
Hyperactive Member
Re: Intellisense Problem
might help if you expand on what you do or would like to do with it?
If a post has been usefull then Rate it! 
-
Mar 9th, 2007, 10:50 AM
#8
Junior Member
Re: List Box Problem
Is this is what your looking for?
It reads a string from a textbox and adds the position of all the spaces to a listbox.
Code:
Dim str1 As String
str1 = Text1.Text
Dim i As Long
For i = 1 To Len(str1)
If Mid$(str1, i, 1) = " " Then
List1.AddItem i
End If
Next
-
Mar 9th, 2007, 10:55 AM
#9
List like Intellisense in RichTextBox
...or do you mean something like this ?
(Add a RichTextBox and a ListBox in a form and paste this code)
vb Code:
' Add a RichTextBox and a ListBox in a form and paste this code
Option Explicit
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any) As Long
Private Const WM_USER As Long = &H400
Private Const EM_POSFROMCHAR As Long = (WM_USER + 38)
Private Sub ShowListBox()
Dim pos As Long
Dim x As Long
Dim y As Long
pos = SendMessage(RichTextBox1.hwnd, EM_POSFROMCHAR, RichTextBox1.SelStart, 0)
Me.Font.Name = RichTextBox1.SelFontName
Me.Font.Size = RichTextBox1.SelFontSize
x = LoWord(pos) * Screen.TwipsPerPixelX + RichTextBox1.Left
y = HiWord(pos) * Screen.TwipsPerPixelY + RichTextBox1.Top + Me.TextHeight("H") + 25
List1.ListIndex = 0
List1.Move x, y
List1.Visible = True
List1.ZOrder 0
List1.SetFocus
End Sub
Function LoWord(DWord As Long) As Integer
If DWord And &H8000& Then ' &H8000& = &H00008000
LoWord = DWord Or &HFFFF0000
Else
LoWord = DWord And &HFFFF&
End If
End Function
Function HiWord(DWord As Long) As Integer
HiWord = (DWord And &HFFFF0000) \ &H10000
End Function
Private Sub Form_Load()
Dim i As Long
With List1
For i = 1 To 25
.AddItem CLng(Rnd * 100000)
Next
.Width = 1440
.Visible = False
End With
End Sub
Private Sub List1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
RichTextBox1.SelText = List1.Text
List1.Visible = False
RichTextBox1.SetFocus
ElseIf KeyAscii = vbKeyEscape Then
List1.Visible = False
RichTextBox1.SetFocus
End If
End Sub
Private Sub RichTextBox1_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
ShowListBox
Else
List1.Visible = False
RichTextBox1.SetFocus
End If
End Sub
-
Mar 9th, 2007, 11:07 AM
#10
Re: Intellisense Problem
Me and others already have replied in your other thread.
Please DO NOT CREATE DUPLICATE THREADS.
If you think your thread title is inappropriate, click the Edit button in the first post and change the title.
-
Mar 9th, 2007, 11:08 AM
#11
Thread Starter
Member
Re: List Box Problem
Like Intellisense In Rich Text Box
-
Mar 9th, 2007, 11:10 AM
#12
-
Mar 9th, 2007, 11:12 AM
#13
Re: List Box Problem
Duplicate threads merged.
Please do not post the same question in multiple threads.
-
Mar 9th, 2007, 11:14 AM
#14
Re: List Box Problem
Float the listbox (.visible = true) at relevant position whenever space is pressed (keypress/keydown event). Hide the listbox (.visible = false) when it loses focus (other controls clicked, TAB pressed), user selects a listitem (RTB selstart, seltext updated accordingly) , or user cancels/presses ESC.
-
Mar 9th, 2007, 11:24 AM
#15
Thread Starter
Member
Re: List Box Problem
Ok Thread Is Resolved Thanks For All
-
Mar 9th, 2007, 11:35 AM
#16
Re: List Box Problem
If you think this thread is resolved, could you please do us a little favour, and mark this thread as Resolved?
(this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)
You can do this by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved".
Also, if you think anyone was particularly helpful (or particularly unhelpful!) you can Rate their post by clicking the link under their name. For more info, see here
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
|