vb6.setitemdata

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pascal

    #1

    vb6.setitemdata


    hello

    i would like to upgrade this code to vbnet, i tried without success:
    Sub ListBoxControl( ByRef sMode As String)

    Dim aryListBox() As String

    Dim aryMain(,) As String

    Dim aryTemp(,) As String

    Dim glWordCount As Integer

    ' *************** *************** *************** **

    ' MODE OPERATION

    ' ---- ---------

    ' SAVE Save the new word

    ' CLEAR Clear the list box

    ' DELETE Remove the selected word

    ' SORT Sort the list from Longest to Shortest word

    ' *************** *************** *************** ***

    Dim lPointer As Integer

    Dim lCount As Integer


    With Me.lstMots

    Select Case UCase(sMode)

    Case "SORT" ' by the longest word to the shortest

    Dim sLastWord As String = ""

    Dim bFlg As Boolean

    Dim lWordCount As Integer

    Dim lUpper As Integer

    Dim bSortLoopFlg As Boolean

    lCount = .Items.Count - 1

    ' *** set the item data to 0

    ' this will be used as a flag later

    For lPointer = 0 To lCount

    vb6.SetItemData (Me.lstMots, lPointer, 0)

    Next

    ReDim aryListBox(0)

    bSortLoopFlg = False

    Do Until bSortLoopFlg = True

    bFlg = True

    bSortLoopFlg = True

    For lPointer = 0 To lCount

    If bFlg = True Then

    ' *** get the first word that the item data is zero

    If VB6.GetItemData (Me.lstMots, lPointer) <> -1 Then

    bSortLoopFlg = False

    ' *** get the first word

    sLastWord = VB6.GetItemStri ng(Me.lstMots, lPointer)

    lWordCount = lPointer

    bFlg = False

    End If '»If .ItemData(lPoin ter) <> -1 Then

    Else

    ' *** get the next word that the item data is zero

    If VB6.GetItemData (Me.lstMots, lPointer) <> -1 Then

    ' *** we still have words to check

    bSortLoopFlg = False

    ' *** find the largest

    If Len(Trim(sLastW ord)) < Len(Trim(VB6.Ge tItemString(Me. lstMots, lPointer)))
    Then

    sLastWord = VB6.GetItemStri ng(Me.lstMots, lPointer)

    lWordCount = lPointer

    End If '»If Len(sLastWord) < .List(lPointer) Then

    End If '»If .ItemData(lPoin ter) <> -1 Then

    End If '»If bFlg = True Then

    Next '»For lPointer = 0 To lCount

    lUpper = UBound(aryListB ox, 1) + 1

    ReDim Preserve aryListBox(lUpp er)

    aryListBox(lUpp er) = sLastWord

    VB6.SetItemData (Me.lstMots, lWordCount, -1)

    Label1.Text = sLastWord

    Loop '»Do Until bSortLoopFlg = True

    Case "DELETE"

    If .SelectedItems. Count = 0 Then Exit Sub

    lCount = .Items.Count - 1

    For lPointer = 0 To lCount

    If .GetSelected(lP ointer) = True Then

    ..Items.RemoveA t(lPointer)

    Exit Sub

    End If '»If .Selected(lPoin ter) = True Then

    Next '»For lPointer = 0 To lCount

    Case "SAVE"

    ..Items.Add(New VB6.ListBoxItem (UCase(Me.txtMo tInput.Text), 0))

    Me.txtMotInput. Text = ""

    Me.txtMotInput. Focus()

    Case "CLEAR"

    ..Items.Clear()

    'Me.txtWord.Tex t = ""

    Me.txtMotInput. Text = ""



    Me.txtMotInput. Focus()

    End Select '»Select Case UCase$(sMode)

    End With '»With frmMain.lstInpu tWord

    End Sub

    End Class


  • Pascal

    #2
    Re: vb6.setitemdata


    You have to add a refference to Microsoft.Visua lBasic.Compatib ility and
    after in the code :
    for example
    :
    For lPr = 0 To lCount

    Compatibility.V B6.SetItemData( Me.listbox1, lPointer, 0) 'instead of
    VB6.SetItemData (Me.listbox1, lPr, 0

    Next




    Ressource pédagogique SC@LPA.



    Comment

    Working...