Results 1 to 16 of 16

Thread: List Box Problem

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    35

    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

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: List Box Problem

    Where the space will be encountered?
    Please mark you thread resolved using the Thread Tools as shown

  3. #3
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: List Box Problem

    Sort of intellisense I might guess.

  4. #4
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    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.
    Doctor Ed

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    35

    Re: List Box Problem

    I Didn't Understand It Clearly Can U Explain It Clearly

  6. #6
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: List Box Problem

    Read up on InStr() function so you'll understand what it is for.

  7. #7
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    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!

  8. #8
    Junior Member
    Join Date
    Mar 2007
    Posts
    19

    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

  9. #9
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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:
    1. ' Add a RichTextBox and a ListBox in a form and paste this code
    2. Option Explicit
    3. Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    4.      ByVal hwnd As Long, _
    5.      ByVal wMsg As Long, _
    6.      ByVal wParam As Long, _
    7.      ByRef lParam As Any) As Long
    8.      
    9. Private Const WM_USER As Long = &H400
    10. Private Const EM_POSFROMCHAR As Long = (WM_USER + 38)
    11.  
    12.  
    13. Private Sub ShowListBox()
    14.     Dim pos As Long
    15.     Dim x As Long
    16.     Dim y As Long
    17.     pos = SendMessage(RichTextBox1.hwnd, EM_POSFROMCHAR, RichTextBox1.SelStart, 0)
    18.     Me.Font.Name = RichTextBox1.SelFontName
    19.     Me.Font.Size = RichTextBox1.SelFontSize
    20.     x = LoWord(pos) * Screen.TwipsPerPixelX + RichTextBox1.Left
    21.     y = HiWord(pos) * Screen.TwipsPerPixelY + RichTextBox1.Top + Me.TextHeight("H") + 25
    22.    
    23.     List1.ListIndex = 0
    24.     List1.Move x, y
    25.     List1.Visible = True
    26.     List1.ZOrder 0
    27.     List1.SetFocus
    28. End Sub
    29.              
    30.    Function LoWord(DWord As Long) As Integer
    31.       If DWord And &H8000& Then ' &H8000& = &H00008000
    32.          LoWord = DWord Or &HFFFF0000
    33.       Else
    34.          LoWord = DWord And &HFFFF&
    35.       End If
    36.    End Function
    37.  
    38.    Function HiWord(DWord As Long) As Integer
    39.       HiWord = (DWord And &HFFFF0000) \ &H10000
    40.    End Function
    41.  
    42. Private Sub Form_Load()
    43.     Dim i As Long
    44.  
    45.     With List1
    46.         For i = 1 To 25
    47.             .AddItem CLng(Rnd * 100000)
    48.         Next
    49.         .Width = 1440
    50.         .Visible = False
    51.     End With
    52. End Sub
    53.  
    54.  
    55. Private Sub List1_KeyPress(KeyAscii As Integer)
    56.     If KeyAscii = 13 Then
    57.         RichTextBox1.SelText = List1.Text
    58.         List1.Visible = False
    59.         RichTextBox1.SetFocus
    60.     ElseIf KeyAscii = vbKeyEscape Then
    61.         List1.Visible = False
    62.         RichTextBox1.SetFocus
    63.     End If
    64. End Sub
    65.  
    66. Private Sub RichTextBox1_KeyPress(KeyAscii As Integer)
    67.     If KeyAscii = 32 Then
    68.         ShowListBox
    69.     Else
    70.         List1.Visible = False
    71.         RichTextBox1.SetFocus
    72.     End If
    73. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  10. #10
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  11. #11

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    35

    Re: List Box Problem

    Like Intellisense In Rich Text Box

  12. #12
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: List Box Problem

    Try my code in post#8.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: List Box Problem

    Duplicate threads merged.

    Please do not post the same question in multiple threads.

  14. #14
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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.

  15. #15

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    35

    Re: List Box Problem

    Ok Thread Is Resolved Thanks For All

  16. #16
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width