السلام عليكم ورحمة الله
في هذا الموضوع هحاول اجمع كل دوال التعامل مع النصوص ولو نسيت حاجة ياريت الاخوة يضفوها لكى تكون مرجع للجميع

طول النص عدد الاحرف

PHP كود :

Dim txt As String = "ABCDEFGHIJK"
'Len
MsgBox(Len(txt)) '11
'Length
MsgBox(txt.Length) '11 


حذف الفراغات المسافات

PHP كود :

Dim txt As String = "  ABCDEFGHIJK  "
'Trim على يمين ويسار النص
MsgBox(Trim(txt))
'Rtrim على يمين النص
MsgBox(RTrim(txt))
'Ltrim على يسار النص
MsgBox(Ltrim(txt)) 



تحويل النص بين كبير وصغير كبتل صمول

PHP كود :

Dim txt As String = "abcdEFGHIJK"
'UCase الى حروف كبيرة
MessageBox.Show(UCase(txt))
'ToUpper الى حروف كبيرة
MessageBox.Show(txt.ToUpper)
'LCase الى حروف صغيرة
MessageBox.Show(LCase(txt))
'ToLower الى حروف صغيرة
MessageBox.Show(txt.ToLower) 


لأخد جزء من النص

PHP كود :

'اذا النص لم يكفى يتم اكمال الباقى فراغات
Dim txt As String = "ABCDEFGHIJK"
'LSet من الجهة اليسرى
MsgBox(LSet(txt, 6)) 'ABCDEF
'RSet من الجهة اليمنى
MsgBox(RSet(txt, 6))
'Mid من البداية التى تحددها
MsgBox(Mid(txt, 3, 6)) 'CDEFGH 


عكس النص

PHP كود :

Dim txt As String = "ABCDEFGHIJK"
'StrReverse
MsgBox(StrReverse(txt)) 'KJIHGFEDCBA 


وضع فرغات مسافات

PHP كود :

Dim txt As String = "ABCDEFGHIJK"
'Space
MsgBox(txt & Space(2) & txt) 'ABCDEFGHIJK  ABCDEFGHIJK 


تحويل النص من والى مصفوفة

PHP كود :

Dim txt As String = "ABC_DEF_GHI_JKL"
'
Dim txt_split() As String = Split(txt, "_")
'
'Split
MsgBox(txt_split(0)) 'ABC
MsgBox(txt_split(1)) 'DEF
MsgBox(txt_split(2)) 'GHI
MsgBox(txt_split(3)) 'JKL
'Join
MsgBox(Join(txt_split)) 'ABC DEF GHI JKL
MsgBox(Join(txt_split, "_")) 'ABC_DEF_GHI_JKL 


مقارنة بين نصين

PHP كود :

'Split
MsgBox(StrComp("ABCD", "ABCD")) ' 0
'
MsgBox(StrComp("ABCD", "ABCZ")) ' 1
'
MsgBox(StrComp("ABCD", "abcd")) '-1
MsgBox(StrComp("ABCD", "abcd", CompareMethod.Text)) ' 0

'Like
MsgBox("ABCDE" Like "ABCDE") 'True
MsgBox("abcde" Like "ABCDE") 'False
'? تعوض عن حرف 
MsgBox("ABCD" Like "?BCD") 'True
'* تعوض عن اى شي
MsgBox("AB2@" Like "*B**") 'True
'# تعوض عن رقم
MsgBox("ABC2" Like "ABC#") 'True
'[-] تعوض من الى
MsgBox("ABC2" Like "[A-Z]BC[1-9]") 'True
'[!-] تعوض ليس من الى
MsgBox("A@BC" Like "A[!a-z]BC") 'True
'[!] ليست العنصر المحدد
MsgBox("ABCD" Like "A[!#]CD") 'True


'= تساوى 
MsgBox("ABCDE" = "ABCDE") 'True
'<> لا تساوى
MsgBox("abcde" <> "ABCDE") 'True 



تكرار نص

PHP كود :

'StrDup
MsgBox(StrDup(8, "A")) 'AAAAAAAA
MsgBox(StrDup(3, "AZ ")) 'AZ AZ AZ 


استبدال نص

PHP كود :

'Replace
Dim txt As String = "ABCDEFGHIJK  ABCDEFGHIJK"
'
MsgBox(Replace(txt, "AB", "ZZ")) 'ZZCDEFGHIJK  ZZCDEFGHIJK
'
MsgBox(Replace(txt, "AB", "ZZ", 14)) 'ZZCDEFGHIJK
'
MsgBox(Replace(txt, "AB", "ZZ", 1, 1)) 'ZZCDEFGHIJK  ABCDEFGHIJK 


معرفة موقع نص

PHP كود :

'InStr
Dim txt As String = "ABCDEFGHIJK"
'
MsgBox(InStr(txt, "sz")) '0
'
MsgBox(InStr(txt, "ef")) '0
'
MsgBox(InStr(txt, "EF")) '5
'
MsgBox(InStr(txt, "ef", CompareMethod.Text)) '5 


معرفة الحرف عن طريق رقمه

PHP كود :

Dim txt As String = "ABCDEFGHIJKL"
'GetChar
MsgBox(GetChar(txt, 4)) 'D 


تعنى سطر او كتابة سطر

PHP كود :

'vbNewLine
Dim txt As String = "ABCDEFGHIJK"
'
MsgBox(txt & vbNewLine & txt)
'ABCDEFGHIJK
'ABCDEFGHIJK 


التعامل مع مكتبات الرموز ( Ascii ) و ( Unicode )

PHP كود :

'Asc
'(ascii code) ترجع بالرمز المقابل فى جدول الرموز
MsgBox(Asc("A")) '65
MsgBox(Asc("E")) '69
'Ascw
'(unicode) ترجع بالرمز المقابل فى جدول الرموز
MsgBox(AscW("A")) '65
MsgBox(AscW("E")) '69
'Chr
'(ascii code) تعيد الحرف المقابل للقيمة فى جدول الرموز
MsgBox(Chr(65)) 'A
'chrw
'(unicode) تعيد الحرف المقابل للقيمة فى جدول الرموز
MsgBox(ChrW(35) & ChrW(13) & ChrW(65))
'#
'A 


حذف جزء من النص

PHP كود :

Dim txt As String = "ABCDEFGHIJKL"
'Remove
MsgBox(txt.Remove(2, 5)) 'ABHIJKL 


دمج نصين

PHP كود :

Dim txt As String = "ABCDEFGHIJKL"
'Insert
MsgBox(txt.Insert(2, "ZZ")) 'ABZZCDEFGHIJKL 


التحقق من وجود نص

PHP كود :

Dim txt As String = "ABCDEFGHIJKL"
'Contains
MsgBox(txt.Contains("A")) 'True
MsgBox(txt.Contains("Z")) 'False 
كود لتنفيد اوامر cmd في vb.net


كود :

Public Class Form1
    Private psi As ProcessStartInfo
    Private cmd As Process
    Private Delegate Sub InvokeWithString(ByVal text As String)
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            cmd.Kill()
        Catch ex As Exception
        End Try
        TextBox2.Clear()
        If TextBox1.Text.Contains(" ") Then
            psi = New ProcessStartInfo(TextBox1.Text.Split(" ")(0), TextBox1.Text.Split(" ")(1))
        Else
            psi = New ProcessStartInfo(TextBox1.Text$)
        End If
        Dim systemencoding As System.Text.Encoding
        System.Text.Encoding.GetEncoding(Globalization.CultureInfo.CurrentUICulture.TextInfo.OEMCodePage)
        With psi
            .UseShellExecute = False
            .RedirectStandardError = True
            .RedirectStandardOutput = True
            .RedirectStandardInput = True
            .CreateNoWindow = True
            .StandardOutputEncoding = systemencoding
            .StandardErrorEncoding = systemencoding
        End With
        cmd = New Process With {.StartInfo = psi, .EnableRaisingEvents = True}
        AddHandler cmd.ErrorDataReceived, AddressOf Async_Data_Received
        AddHandler cmd.OutputDataReceived, AddressOf Async_Data_Received
        cmd.Start()
        cmd.BeginOutputReadLine()
        cmd.BeginErrorReadLine()
    End Sub
    Private Sub Async_Data_Received(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
        Me.Invoke(New InvokeWithString(AddressOf Sync_Output), e.Data)
    End Sub
    Private Sub Sync_Output(ByVal text As String)
        TextBox2.AppendText(text & Environment.NewLine)
        TextBox2.ScrollToCaret()
    End Sub
End Class
التعامل مع ملفات الجهاز ( إنشاء ، كتابة ، نقل ، نسخ )

السلام عليكم و رحمه الله و بركاته

اقدم اليكم 4 اكواد للتعامل مع الملفات بمختلف صيغها ..

صنع ملف txt : 

كود :

My.Computer.FileSystem.WriteAllText("C:\Test.txt", String.Empty, False)


كتابة علي الملف txt :

كود :

My.Computer.FileSystem.WriteAllText("TheFile.txt", "TextContents", False)


نقل الملفات من مكان لآخر بمختلف الصيغ :

كود :

My.Computer.FileSystem.MoveFile("C:\OldDirectory\File.txt", "c:\NewDirectory\File.txt")


نسخ الملفات من مكان لآخر بمختلف الصيغ :

كود :

My.Computer.FileSystem.CopyFile("C:\Source.txt", "C:\NewFolder\Dest.txt")


تحياتي لكم و تمنياتي لكم بالتوفيق