convert autocomplete vb6 to vb.net

convert autocomplete vb6 to vb.net

Page 1 of 1

7 Replies - 5696 Views - Last Post: 12 October 2010 - 06:04 AM Rate Topic: -----

#1 jigulo  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 12-October 10

convert autocomplete vb6 to vb.net

Posted 12 October 2010 - 02:06 AM

http://www.dreaminco..._post&f=67.htm#

i have sample code in vb6
can you pls help me convert to vb.net pls

here's my sample code

Function autoname(ctl2 As Control, KeyAscii As Integer)
Dim tem
Dim rtem
Dim tps
Dim css As Integer
Dim i As Integer

If KeyAscii = 8 Or KeyAscii = 13 Then
GoTo en
ElseIf KeyAscii >= 123 And KeyAscii <= 126 Then
KeyAscii = 0
GoTo en
ElseIf KeyAscii >= 91 And KeyAscii <= 96 Then
KeyAscii = 0
GoTo en
ElseIf KeyAscii >= 33 And KeyAscii <= 64 Then
KeyAscii = 0
GoTo en
ElseIf KeyAscii >= 65 And KeyAscii <= 90 Then

ElseIf KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32
Else
KeyAscii = ValidChars(KeyAscii)
End If

If ctl2.SelLength = 0 Then
ctl2.Text = ctl2.Text & Chr(KeyAscii)
ElseIf ctl2.SelLength > 0 And KeyAscii = 32 Then
ctl2.Text = ctl2.Text & " "
ctl2.SelStart = Len(ctl2.Text)
KeyAscii = 0
Exit Function
ElseIf ctl2.SelLength > 0 Then
ctl2.Text = Left(ctl2.Text, Len(ctl2.Text) - ctl2.SelLength) & Chr(KeyAscii)
End If
ctl2.SelStart = Len(ctl2.Text)

If KeyAscii = 32 Then
If DoubleSpace(ctl2.Text) = " " Then
GoTo er
End If
tem = Trim(ctl2.Text)
tem = Split(tem, " ")
If Len(tem(UBound(tem))) > 2 And UBound(tem) > 0 Then
If InStr(tem(UBound(tem)), vbCrLf) = 0 Then
If Len(tem(UBound(tem))) > 2 Then List2.AddItem tem(UBound(tem))
Else
Dim ttem
ttem = Split(tem(UBound(tem)), vbCrLf)
If Len(ttem(UBound(ttem))) > 2 Then List2.AddItem ttem(UBound(ttem))
End If
Else
Set tem = Nothing
tem = Split(ctl2.Text, vbCrLf)
If InStr(Trim("" & tem(UBound(tem)) & ""), " ") = 0 Then
If Len(Trim("" & tem(UBound(tem)) & "")) > 2 Then List2.AddItem Trim("" & tem(UBound(tem)) & "")
Else
rtem = Split(Trim("" & tem(UBound(tem)) & ""), " ")
If Len(rtem(UBound(rtem))) > 2 Then List2.AddItem rtem(UBound(rtem))
End If
End If
'RemoveDups List2
er:
Else
tps = Split(ctl2.Text, " ")
If UBound(tps) = 0 Or InStr(tps(UBound(tps)), vbCrLf) > 0 Then
Set tps = Nothing
tps = Split(ctl2.Text, vbCrLf)
End If
css = Len(ctl2.Text)
For i = 0 To List2.ListCount - 1
If Len(tps(UBound(tps))) > 0 Then
If StrComp(tps(UBound(tps)), Left(List2.List(i), Len(Trim("" & tps(UBound(tps)) & ""))), vbTextCompare) = 0 Then
ctl2.Text = ctl2.Text & Right(List2.List(i), Len(List2.List(i)) - Len(Trim("" & tps(UBound(tps)) & "")))
ctl2.SelStart = css
ctl2.SelLength = Len(ctl2.Text) - css
Exit For
End If
Else
Exit For
End If
Next i
End If
If KeyAscii <> 13 Then KeyAscii = 0
en:

End Function


Private Sub text1_KeyPress(KeyAscii As Integer)

autoname text1, KeyAscii

End Sub

This post has been edited by jigulo: 12 October 2010 - 02:10 AM


Is This A Good Question/Topic? -1
  • +

Replies To: convert autocomplete vb6 to vb.net

#2 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: convert autocomplete vb6 to vb.net

Posted 12 October 2010 - 02:09 AM

What is this? why do you add a link that ADDS a new Topic? What is your question any how?
Was This Post Helpful? 0
  • +
  • -

#3 jigulo  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 12-October 10

Re: convert autocomplete vb6 to vb.net

Posted 12 October 2010 - 02:18 AM

View Postmotcom, on 12 October 2010 - 01:09 AM, said:

What is this? why do you add a link that ADDS a new Topic? What is your question any how?


sorry im a new member here help me to convert this code to vb.net pls 1st is function autocomplete the 2nd is how to call in a textbox can you help me ?

This post has been edited by jigulo: 12 October 2010 - 02:19 AM

Was This Post Helpful? 0
  • +
  • -

#4 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: convert autocomplete vb6 to vb.net

Posted 12 October 2010 - 02:38 AM

Why do you need to convert it?

The Textbox Does have a AutoComplete fuction, you can bind it to all sorts of Lists and Files etc...
Was This Post Helpful? 0
  • +
  • -

#5 jigulo  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 12-October 10

Re: convert autocomplete vb6 to vb.net

Posted 12 October 2010 - 05:45 AM

View Postmotcom, on 12 October 2010 - 01:38 AM, said:

Why do you need to convert it?

The Textbox Does have a AutoComplete fuction, you can bind it to all sorts of Lists and Files etc...


i want to build same program like this in vb.net ok tnx in advance
Was This Post Helpful? 0
  • +
  • -

#6 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: convert autocomplete vb6 to vb.net

Posted 12 October 2010 - 05:51 AM

jigulo,
It appears you haven't read motcoms's response thoroughly enough.

The textbox has what you're trying to convert, built into it in .NET.

You can even set the AutoCompleteSource to the listitems of your listbox

This post has been edited by CharlieMay: 12 October 2010 - 05:58 AM

Was This Post Helpful? 0
  • +
  • -

#7 jigulo  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 12-October 10

Re: convert autocomplete vb6 to vb.net

Posted 12 October 2010 - 06:01 AM

View PostCharlieMay, on 12 October 2010 - 04:51 AM, said:

jigulo,
It appears you haven't read motcoms's response thoroughly enough.

The textbox has what you're trying to convert, built into it in .NET.

You can even set the AutoCompleteSource to the listitems of your listbox


ok tnx my friend
Was This Post Helpful? 0
  • +
  • -

#8 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: convert autocomplete vb6 to vb.net

Posted 12 October 2010 - 06:04 AM

No problem,
Look up the help section on AutoCompleteMode, AutoCompleteCustomSource and there are examples of using them.

As far as blocking certain keypresses, you can check out this snippit I did on limiting what you allow to be entered into a textbox.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1