Click here to Skip to main content
15,887,439 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Option Strict Off
Option Explicit On
Friend Class Form1
	Inherits System.Windows.Forms.Form
	Dim counter As Short
	Dim search As Object
	Dim se As String
	'UPGRADE_WARNING: Event C.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    
    Private Sub l_DoubleClick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtRead.DoubleClick
        MsgBox(txtRead.Text)
    End Sub

    Private Sub txtWrite_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtWrite.TextChanged
        
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        txtRead.Items.Clear()
        txtcount.Text = CStr(0)
        If Len(txtWrite.Text) <> 0 Then
            se = txtWrite.Text
            txtcount.Text = CStr(0)
            FileOpen(1, "C:\search.txt", OpenMode.Input)
            While Not EOF(1)
                txtcount.Text = CStr(CDbl(txtcount.Text) + 1)
                Input(1, search)
                For counter = 1 To Len(search)
                    
                    If Mid(se, 1, Len(txtWrite.Text)) = Mid(search, counter, Len(txtWrite.Text)) Then
                        txtRead.Items.Add((search))

                    End If
                Next
            End While
            FileClose(1)
        End If
        txtcount.Text = txtRead.Items.Count & "/" & txtcount.Text
    End Sub
End Class

I have 1 text file in debug folder "city name.txt"
lahore        لاہور
gujrat        گجرات
shaikhupura       شیخوپورہ
hadraabad         حیدرآباد
ect

My Project name search city name.vb vb.net 2005
1 textbox txtCsearch
2 textbox txtNameCity
textbox 1 key press event
textbox 2 open search Result

English words are open, but Urdu Words are not opened.
Urdu words to search for what to do?

Please help me
zaka
Posted
Updated 26-Feb-12 3:09am
v2
Comments
André Kraak 26-Feb-12 9:09am    
Edited question:
Added pre tags
Sergey Alexandrovich Kryukov 26-Feb-12 21:29pm    
There is no such problem, not at all. You problem is: using legacy VB stuff instead of .NET and not understanding Unicode. Please see my answer.
--SA

1 solution

There is absolutely no difference what is the language, Urdu or English unless you loose Unicode information. Your input file should use one of Unicode UTFs for encoding.

Avoid using CStr. This is a legacy cast operator. You never need it. Instead, use object.ToString. You don't need it for this task at all.

Your code is hard to understand, but the search is really simple.

Make sure you read text file correctly. For text files, use System.IO.StreamReader, see:
http://msdn.microsoft.com/en-us/library/system.io.streamreader%28v=vs.100%29.aspx[^].

In most cases, you need to open text files, ASCII and Unicode, using encoding detection based on BOM (see below). ASCII files do not contain BOM, which is also detected correctly. Use this constructor with second parameter set to true:
http://msdn.microsoft.com/en-us/library/9y86s1a9.aspx[^].

If you know that in some files BOM is not present but you know the encoding, you can pass encoding explicitly. In this case, use this:
http://msdn.microsoft.com/en-us/library/x8xxf0x5.aspx[^].

Read the file line by line using System.IO.StreamReader.ReadLine or read the whole file using ReadToEnd. Use other read methods when required.

Search for substring in a string using System.String.IndexOf methods:
http://msdn.microsoft.com/en-us/library/system.string.aspx[^].

In general, stop using legacy VB stuff. Use .NET!

Also, you need to understand main ideas of Unicode. Please see:
http://unicode.org/[^],
http://unicode.org/faq/utf_bom.html[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900