Results 1 to 2 of 2

Thread: My search function doesnt work

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Posts
    178

    My search function doesnt work

    im wondering why my search function doesnt work supposed to be if you gonna press a letter then it it look for the first letter of the topic

    here is my code;

    VB Code:
    1. Dim Ctr As Integer
    2. Dim Leng As Integer
    3. Dim PiC As String
    4. Dim PiC2 As String
    5. Private Sub Form_Activate()
    6. Call Hide_Images
    7. List1.Clear
    8. Data1.Recordset.MoveFirst
    9. Data1.Recordset.MoveNext
    10. Data1.Recordset.MovePrevious
    11. For Ctr = 1 To Data1.Recordset.RecordCount
    12.     List1.AddItem Text3
    13.     Data1.Recordset.MoveNext
    14. Next Ctr
    15. Text1 = ""
    16. End Sub
    17.  
    18. Private Sub Image19_Click()
    19.  
    20. End Sub
    21.  
    22. Private Sub List1_Click()
    23. Data1.Recordset.MoveFirst
    24. Data1.Recordset.MoveNext
    25. Data1.Recordset.MovePrevious
    26. For Ctr = 1 To Data1.Recordset.RecordCount
    27.     If List1.Text = Text3 Then
    28.         Ctr = Data1.Recordset.RecordCount
    29.     Else
    30.         If Data1.Recordset.EOF Then
    31.             Data1.Recordset.MoveFirst
    32.         Else
    33.             Data1.Recordset.MoveNext
    34.         End If
    35.     End If
    36. Next Ctr
    37. End Sub
    38.  
    39. Private Sub Text1_KeyPress(KeyAscii As Integer)
    40. Timer1.Interval = 1
    41. End Sub
    42.  
    43. Private Sub Timer1_Timer()
    44. Text1 = LCase(Text1)
    45. Leng = Len(Text1)
    46. Text3.SetFocus
    47. Data1.Recordset.MoveFirst
    48. Data1.Recordset.MoveNext
    49. Data1.Recordset.MovePrevious
    50. For Ctr = 1 To Data1.Recordset.RecordCount
    51.     Text3.SelStart = 0
    52.     Text3.SelLength = Leng
    53.     If Text1 = Text3.SelText Then
    54.         List1.Text = Text3
    55.         Ctr = Data1.Recordset.RecordCount
    56.         Text1.SetFocus
    57.         Text1.SelStart = Len(Text1)
    58.     Else
    59.         If Ctr = Data1.Recordset.RecordCount Then
    60.             Text1.SetFocus
    61.             Text1.SelStart = Len(Text1)
    62.         Else
    63.             If Data1.Recordset.EOF Then
    64.                 Data1.Recordset.MoveFirst
    65.             Else
    66.                 Data1.Recordset.MoveNext
    67.             End If
    68.         End If
    69.     End If
    70. Next Ctr
    71. Timer1.Interval = 0
    72. End Sub
    73.  
    74. Private Sub Timer2_Timer()
    75. If Label3 = List1.Text Then
    76.  
    77. Else
    78.     Label3 = Text3
    79.     Text2 = Text4
    80. End If
    81. End Sub
    82.  
    83. Private Sub Hide_Images()
    84. Image1.Visible = False
    85. Image2.Visible = False
    86. Image3.Visible = False
    87. Image4.Visible = False
    88. Image5.Visible = False
    89. Image6.Visible = False
    90. Image7.Visible = False
    91. Image8.Visible = False
    92. Image9.Visible = False
    93. Image10.Visible = False
    94. Image11.Visible = False
    95. Image12.Visible = False
    96. Image13.Visible = False
    97.  
    98. End Sub
    99.  
    100. Private Sub Timer3_Timer()
    101. PiC = Label4
    102. If PiC2 = PiC Then
    103.  
    104. Else
    105.     If PiC = "" Then
    106.         Call Hide_Images
    107.     End If
    108.     If PiC = "example01" Then
    109.         Call Hide_Images
    110.         Image1.Visible = True
    111.     End If
    112.     If PiC = "example02" Then
    113.         Call Hide_Images
    114.         Image2.Visible = True
    115.     End If
    116.     If PiC = "example03" Then
    117.         Call Hide_Images
    118.         Image3.Visible = True
    119.     End If
    120.     If PiC = "example04" Then
    121.         Call Hide_Images
    122.         Image4.Visible = True
    123.     End If
    124.     If PiC = "example05" Then
    125.         Call Hide_Images
    126.         Image5.Visible = True
    127.     End If
    128.     If PiC = "example06" Then
    129.         Call Hide_Images
    130.         Image6.Visible = True
    131.     End If
    132.     If PiC = "example07" Then
    133.         Call Hide_Images
    134.         Image7.Visible = True
    135.     End If
    136.     If PiC = "example08" Then
    137.         Call Hide_Images
    138.         Image8.Visible = True
    139.     End If
    140.     If PiC = "example09" Then
    141.         Call Hide_Images
    142.         Image9.Visible = True
    143.     End If
    144.     If PiC = "example10" Then
    145.         Call Hide_Images
    146.         Image10.Visible = True
    147.     End If
    148.     If PiC = "example11" Then
    149.         Call Hide_Images
    150.         Image11.Visible = True
    151.     End If
    152.         If PiC = "example12" Then
    153.         Call Hide_Images
    154.         Image12.Visible = True
    155.     End If
    156.     If PiC = "example13" Then
    157.         Call Hide_Images
    158.         Image13.Visible = True
    159.     End If
    160.  
    161. End If
    162. PiC2 = PiC
    163. End Sub

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: My search function doesnt work

    Just a hint:

    VB Code:
    1. If PiC = "" Then
    2.         Call Hide_Images
    3.     End If
    4.     If PiC = "example01" Then
    5.         Call Hide_Images
    6.         Image1.Visible = True
    7.     End If
    8.     If PiC = "example02" Then
    9.         Call Hide_Images
    10.         Image2.Visible = True
    11.     End If
    12.     If PiC = "example03" Then
    13.         Call Hide_Images
    14.         Image3.Visible = True
    15.     End If
    16.     If PiC = "example04" Then
    17.         Call Hide_Images
    18.         Image4.Visible = True
    19.     End If
    20.     If PiC = "example05" Then
    21.         Call Hide_Images
    22.         Image5.Visible = True
    23.     End If
    24.     If PiC = "example06" Then
    25.         Call Hide_Images
    26.         Image6.Visible = True
    27.     End If
    28.     If PiC = "example07" Then
    29.         Call Hide_Images
    30.         Image7.Visible = True
    31.     End If
    32.     If PiC = "example08" Then
    33.         Call Hide_Images
    34.         Image8.Visible = True
    35.     End If
    36.     If PiC = "example09" Then
    37.         Call Hide_Images
    38.         Image9.Visible = True
    39.     End If
    40.     If PiC = "example10" Then
    41.         Call Hide_Images
    42.         Image10.Visible = True
    43.     End If
    44.     If PiC = "example11" Then
    45.         Call Hide_Images
    46.         Image11.Visible = True
    47.     End If
    48.         If PiC = "example12" Then
    49.         Call Hide_Images
    50.         Image12.Visible = True
    51.     End If
    52.     If PiC = "example13" Then
    53.         Call Hide_Images
    54.         Image13.Visible = True
    55.     End If
    Use ElseIf instead If End If, If End If... You just need one End If, and it's much faster.

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