Results 1 to 19 of 19

Thread: [RESOLVED] listbox to popup ...how?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Resolved [RESOLVED] listbox to popup ...how?

    could you please help me with this ?

    form1... contains a richtext box with some words
    form2... contains two lists with some group of words saperated by an empty field
    for example

    list1
    ocean
    The Deep
    Marine

    choose
    decide on
    Pick


    list2
    22
    66
    87

    57
    93
    11




    how can i assign apopup menu for wach word in form 1 with the valus of these lists

    as folows


    the first word in text is (sea)
    popup menu will be
    ocean <22>
    The Deep <66>
    Marine <87>
    then if the user select one of these options (sea) will be replased by that option

    the second word in text is (select)
    popup menu sholud be
    choose <57>
    decide on < 93>
    Pick < 11>



    if the user picked ocean <22> in the first case and decide on < 93> in the second case

    the text will be shown as
    ocean<22> decide on< 93>


    and thats it pleeeease help me

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: listbox to popup ...how?

    why are u using listboxes for these word?
    how many "choices" will there be? (is it going to be more than sea and select)??
    why have a second listbox that has the numbers in it?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: listbox to popup ...how?

    do u want multi line popup... then

    http://vbforums.com/showthread.php?&...&is_resolved=1

    check out this link

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: listbox to popup ...how?

    I think they want a popup menu... so user can select a word and it replaces it
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox to popup ...how?

    STATIC....

    if you remeber this thread

    [URL=http://www.vb-forums.com/showthread.php?t=418760[/URL]

    these two words and the numbers are just to simplyfy the idea
    because the actual project deals with arabic text

    as u see in the URL

    ....from the beging i choose to extract the options of each word as you told me and put them in a list box then i did the same thing to get the english translation for each option and put them in another list

    .... i don't know the number of words in the text, it is different text in each run

    my questions now :

    is it possible to divide the list box and convert it to a popup for each word?
    can i merg the two lists each row togather ?
    how can i replace the choosen option with the original woed in the text?


    i hope that i explaind well

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox to popup ...how?

    SHAKTI 5385
    thanks i well check this

  7. #7
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: listbox to popup ...how?

    oh yeah, that thread.

    I would suggest dropping the idea of the listbox. or, do u really need to see these words? or only on right click?

    I would create text file, or store in a variable.. split up...
    somthing like this:

    sea;ocean <22>;The Deep <66>;Marine <87>
    select;choose <57>;decide on <93>;Pick <11>

    then you can loop thru and check the first word if its the selected word, you can build the popup with the rest of the line

    is the INPUT the "word"? or is Lookup the Word?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  8. #8
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: listbox to popup ...how?

    here is a sample project. .it is using the Lookup word as the possible match from the rich textbox... let me know if u want it to use the input string...

    this will build a menu for the highlighted word... then replaced if clicked.
    Attached Files Attached Files
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox to popup ...how?

    it is the INPUT

    .. no i don't need to see the words

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox to popup ...how?

    i run the project STATIC thanks
    this is what i mean
    but can popup menu appear whith right click the word without selecting it

  11. #11
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: listbox to popup ...how?

    sure, heres another question...
    should the "lookup word" be ignored?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  12. #12
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: listbox to popup ...how?

    ok replace the code in the sample project with the code below..

    a few notes....
    1 (sorry the sample had a listbox and command button... leftover from testing)
    2 I cannot test since the "INPUT string" is in arabic, I cant check it, only shows ????? in my test files.. so hopefull it will work for you
    3 either select the word, or click in it then right click, menu should appear

    any questions on the code, just yell
    VB Code:
    1. Dim WORDLIST() As String
    2.  
    3. Private Sub GetData()
    4.     Dim tW As String
    5.     Dim tmp() As String
    6.     Dim Words() As String
    7.     Open App.Path & "\arabic.txt" For Input As #1
    8.         tmp = Split(Input(LOF(1), 1), vbCrLf)
    9.     Close #1
    10.     Dim sLine As String
    11.     For x = 0 To UBound(tmp)
    12.        
    13.         If UCase(Left(tmp(x), 8)) = "SOLUTION" Then
    14.             Words = Split(tmp(x), "(")
    15.             sLine = sLine & Left(Words(1), InStr(Words(1), ")") - 1) & ";"
    16.         ElseIf UCase(Left(tmp(x), 7)) = "COMMENT" Then
    17.             Words = Split(tmp(x), ":")
    18.             sLine = sLine & Words(1)
    19.         ElseIf UCase(Left(tmp(x), 5)) = "INPUT" Then
    20.             If sLine <> "" Then
    21.                 If Right(sLine, 1) = ";" Then
    22.                     sLine = Left(sLine, Len(sLine) - 1)
    23.                 End If
    24.                 sLine = sLine & vbCrLf
    25.             End If
    26.             Words = Split(tmp(x), ":")
    27.             sLine = sLine & Trim(Words(1)) & ":"
    28.         ElseIf UCase(Left(tmp(x), 7)) = "LOOK-UP" Then
    29.             'nothing
    30.         End If
    31.     Next
    32.     Debug.Print sLine
    33.     WORDLIST = Split(sLine, vbCrLf)
    34.    
    35.  
    36. End Sub
    37.  
    38.  
    39. Private Sub Form_Load()
    40.    GetData
    41.    RichTextBox1.Text = "not sure what to put here...."
    42. End Sub
    43.  
    44.  
    45.  
    46. Private Sub mnuWord_Click(Index As Integer)
    47.     If InStr(mnuWord(Index).Caption, "NOT FOUND") = 0 Then
    48.         RichTextBox1.SelText = mnuWord(Index).Caption
    49.     End If
    50. End Sub
    51.  
    52. Private Sub RichTextBox1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    53.     If Button = 2 Then
    54.         Dim sLoc As Integer, eLoc As Integer
    55.         Dim wrds() As String
    56.         Dim tmp() As String
    57.         If Trim(RichTextBox1.SelText) = "" Then
    58.             If RichTextBox1.SelStart = 0 Then Exit Sub
    59.             sLoc = InStrRev(RichTextBox1.Text, " ", RichTextBox1.SelStart)
    60.             eLoc = InStr(RichTextBox1.SelStart, RichTextBox1.Text, " ") - 1
    61.             RichTextBox1.SelStart = sLoc
    62.             RichTextBox1.SelLength = eLoc - sLoc
    63.         End If
    64.         If Trim(RichTextBox1.SelText) <> "" Then
    65.             For x = mnuWord.UBound To 1 Step -1
    66.                 Unload mnuWord(x)
    67.             Next
    68.             mnuWord(0).Caption = "NOT FOUND"
    69.             For x = 0 To UBound(WORDLIST)
    70.                 tmp = Split(WORDLIST(x), ":")
    71.                 If tmp(0) = Trim(RichTextBox1.SelText) Then
    72.                     wrds = Split(tmp(1), ";")
    73.                     For I = 0 To UBound(wrds)
    74.                         If I = 0 Then
    75.                             mnuWord(0).Caption = wrds(I)
    76.                         Else
    77.                             Load mnuWord(I)
    78.                             mnuWord(I).Visible = True
    79.                             mnuWord(I).Caption = wrds(I)
    80.                         End If
    81.                     Next
    82.                 End If
    83.             Next
    84.             PopupMenu mnuPop
    85.         End If
    86.     End If
    87.    
    88. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox to popup ...how?

    yes "lookup word" should be ignored

    thnks i will check this and tell you
    thank u again

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox to popup ...how?

    thanks STATIC
    it works nicely

    can i add the english translation to the popup for each option
    the translations are between two plus signs +

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox to popup ...how?

    oh there is an error said
    (run time error '380' invalid property value'
    points to this code
    VB Code:
    1. RichTextBox1.SelLength = eLoc - sLoc

    specially when i click the last word in the text

    what is the problem??

  16. #16
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: listbox to popup ...how?

    sure...
    this will add it...

    but, u will need To change the "replace" Option so it does Not insert the translation As well

    VB Code:
    1. Private Sub GetData()
    2.     Dim tW As String
    3.     Dim tmp() As String
    4.     Dim Words() As String
    5.     Dim gloss() As String
    6.     Open App.Path & "\arabic.txt" For Input As #1
    7.         tmp = Split(Input(LOF(1), 1), vbCrLf)
    8.     Close #1
    9.     Dim sLine As String
    10.     For x = 0 To UBound(tmp)
    11.          
    12.         If UCase(Left(tmp(x), 8)) = "SOLUTION" Then
    13.             Words = Split(tmp(x), "(")
    14.             If UCase(Left(tmp(x + 1), 7)) = "(GLOSS)" Then
    15.                 sLine = sLine & Left(Words(1), InStr(Words(1), ")") - 1)
    16.                 gloss = Split(tmp(x + 1), "+")
    17.                 sLine = sLine & " (" & Trim(gloss(1)) & ");"
    18.             Else
    19.                 sLine = sLine & Left(Words(1), InStr(Words(1), ")") - 1) & ";"
    20.             End If
    21.         ElseIf UCase(Left(tmp(x), 7)) = "COMMENT" Then
    22.             Words = Split(tmp(x), ":")
    23.             sLine = sLine & Words(1)
    24.         ElseIf UCase(Left(tmp(x), 5)) = "INPUT" Then
    25.             If sLine <> "" Then
    26.                 If Right(sLine, 1) = ";" Then
    27.                     sLine = Left(sLine, Len(sLine) - 1)
    28.                 End If
    29.                 sLine = sLine & vbCrLf
    30.             End If
    31.             Words = Split(tmp(x), ":")
    32.             sLine = sLine & Trim(Words(1)) & ":"
    33.         ElseIf UCase(Left(tmp(x), 7)) = "LOOK-UP" Then
    34.             'nothing
    35.         End If
    36.     Next
    37.     Debug.Print sLine
    38.     WORDLIST = Split(sLine, vbCrLf)
    39.      
    40.  
    41. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox to popup ...how?

    thanks

    very good

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox to popup ...how?

    Static
    i know that u r so busy
    but could u please explain each line of code

    because i need to undrstand every line

  19. #19
    Member
    Join Date
    Aug 2006
    Location
    Arabian Gulf
    Posts
    46

    Question Re:popup ...how?

    Hi Static...
    I used you code in replay #12, because I have in my program PopUp menu that appear by right click with some words (translation words), when we select the word from menu it is show next to the word in RichTextBox and if i select another word it show also next to it.
    But I want to delete the first word i selected and print the second word i select it from menu.
    How can I do that?

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