Imports System.IO Imports System.Text.RegularExpressions Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles changes.Click If (folder.Text = "") Then MsgBox("تکایە فولدەرەکە دەست نیشان بکە") Return End If If (count.Text = "") Then MsgBox("تکایە فایلی ناوەکان داخل بکە") Return End If renameFilesInFolder() End Sub Private Sub renameFilesInFolder() On Error Resume Next Dim sourcePath As String = folder.Text Dim searchPattern As String = "*.mp3" Dim text As String = "" Dim files() As String = IO.Directory.GetFiles(sourcePath) 'For Each sFile As String In files ' text &= IO.File.ReadAllText(sFile) ' 'My.Computer.FileSystem.RenameFile(sourcePath + IO.File.ReadAllText(sFile), "reza") ' ListBox1.Items.Add(IO.File.ReadAllText(sFile)) 'Next Dim i As Integer = 0 ListBox1.SelectedIndex = 0 ListBox2.SelectedIndex = 0 For i = 0 To ListBox1.Items.Count - 1 Dim cleanString As String = Regex.Replace(ListBox1.SelectedItem, "[^A-Za-z0-9\-/]", "") File.Move(Path.Combine(sourcePath, ListBox2.SelectedItem), Path.Combine(sourcePath, cleanString.Replace("/", ""))) ListBox1.SelectedIndex = i + 1 ListBox2.SelectedIndex = i + 1 'i += 1 'If (i <= ListBox1.Items.Count) Then ' ListBox1.SelectedIndex = i ' ListBox2.SelectedIndex = i 'End If Next #If False Then For Each fileName As String In Directory.GetFiles(sourcePath, searchPattern, SearchOption.AllDirectories).OrderBy(Function(fi) fi.n).ToArray() ' My.Computer.FileSystem.RenameFile(sourcePath + fileName, ListBox1.SelectedItem) 'Dim sel As String = ListBox1.SelectedItem.ToString.Replace("/", "&") ' Dim cleanString As String = Regex.Replace(ListBox1.SelectedItem, "[^A-Za-z0-9\-/]", "") ' File.Move(Path.Combine(sourcePath, fileName), Path.Combine(sourcePath, cleanString.Replace("/", ""))) File.Move(Path.Combine(sourcePath, fileName), Path.Combine(sourcePath, ListBox1.SelectedItem)) i += 1 If (i <= ListBox1.Items.Count - 1) Then ListBox1.SelectedIndex = i ListBox2.SelectedIndex = i End If Next #End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles ch_folder.Click Dim FolderBrowserDialog1 = New FolderBrowserDialog() If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then folder.Text = FolderBrowserDialog1.SelectedPath Dim di As New IO.DirectoryInfo(FolderBrowserDialog1.SelectedPath) End If End Sub Private Sub OpenList(ListBox, Label) Dim openfile = New OpenFileDialog() openfile.Filter = "Text (*.txt)|*.txt" If (openfile.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then ListBox.Items.Clear() Dim myfile As String = openfile.FileName Dim allLines As String() = File.ReadAllLines(myfile) For Each line As String In allLines ListBox.Items.Add(line) Next Label.Text = ListBox.Items.Count - 1 folder.Text = openfile.FileName.Replace(".txt", "") End If End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles names.Click OpenList(ListBox1, count) End Sub Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click OpenList2(ListBox2, Label1) End Sub Private Sub OpenList2(ListBox, Label) ListBox.Items.Clear() For i = 0 To ListBox1.Items.Count - 1 ListBox.Items.Add("a_" + (i + 1).ToString + ".ttf") Next Label.Text = ListBox.Items.Count - 1 End Sub End Class
Write, Run & Share VB.net code online using OneCompiler's VB.net online compiler for free. It's one of the robust, feature-rich online compilers for VB.net language, running on the latest version 16. Getting started with the OneCompiler's VB.net compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as VB.net
. OneCompiler also has reference programs, where you can look for the sample code to get started with.
OneCompiler's VB.net online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample VB.net program which takes name as input and prints hello message with your name.
Public Module Program
Public Sub Main(args() As string)
Dim name as String = Console.ReadLine() ' Reading input from STDIN
Console.WriteLine("Hello " & name) ' Writing output to STDOUT
End Sub
End Module
Visual Basic is a event driven programming language by Microsoft, first released in the year 1991.
Variable is a name given to the storage area in order to identify them in our programs.
Simple syntax of Variable declaration is as follows
Dim variableName [ As [ New ] dataType ] [ = initializer ]
variableName = value
If condition-expression Then
'code
End If
If(conditional-expression)Then
'code if the conditional-expression is true
Else
'code if the conditional-expression is false
End If
If(conditional-expression)Then
'code if the above conditional-expression is true
Else If(conditional-expression) Then
'code if the above conditional-expression is true
Else
'code if the above conditional-expression is false
End If
If(conditional-expression)Then
'code if the above conditional-expression is true
If(conditional-expression)Then
'code if the above conditional-expression is true
End If
End If
Select [ Case ] expression
[ Case expressionlist
'code ]
[ Case Else
'code ]
End Select
For counter [ As datatype ] = begin To end [ Step step ]
'code
[ Continue For ]
'code
[ Exit For ]
'code
Next [ counter ]
For Each element [ As datatype ] In group
'code
[ Continue For ]
'code
[ Exit For ]
'code
Next [ element ]
While conditional-expression
'Code
[ Continue While ]
'Code
[ Exit While ]
'Code
End While
Do { While | Until } conditional-expression
'Code
[ Continue Do ]
'Code
[ Exit Do ]
'Code
Loop
Do
'Code
[ Continue Do ]
'Code
[ Exit Do ]
'Code
Loop { While | Until } conditional-expression
Procedure is a sub-routine which contains set of statements. Usually Procedures are written when multiple calls are required to same set of statements which increases re-usuability and modularity.
Procedures are of two types.
Functions return a value when they are called.
[accessModifiers] Function functionName [(parameterList)] As returnType
'code
End Function
Sub-procedures are similar to functions but they don't return any value.
Sub ProcedureName (parameterList)
'Code
End Sub