Programming for Everybody: October 2020

How to Copy Selected File to selected Folder Using VB.NET

 



Imports System.IO

Public Class Form3

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        OpenFileDialog1.ShowDialog()
        TextBox1.Text = Path.GetFileName(OpenFileDialog1.FileName)
        TextBox2.Text = Path.GetDirectoryName(OpenFileDialog1.FileName) & "\" & Path.GetFileName(OpenFileDialog1.FileName)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        FolderBrowserDialog1.ShowDialog()

        TextBox3.Text = FolderBrowserDialog1.SelectedPath.ToString


    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        If System.IO.File.Exists(TextBox3.Text & "\" & TextBox1.Text) Then

            'MsgBox("the file exists")

            File.AppendAllText(TextBox2.Text, TextBox3.Text & "\" & TextBox1.Text)

        Else

            File.Copy(TextBox2.Text, TextBox3.Text & "\" & TextBox1.Text)

            MsgBox("file copied successfully")


        End If





    End Sub

End Class

CSS text-transform Property(none-lowercase-uppercase-capitalize )

 div.a {

  text-transform: uppercase;

}


div.b {

  text-transform: lowercase;

}


div.c {

  text-transform: capitalize;

}

Default Value 
text-transform: none;

How to get value selected item from combobox in VB.NET-with source code

 


Imports System.Data.SqlClient


Public Class Form5


    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim con As New SqlConnection(" data source=.;initial catalog=sports1;integrated security=true")


        Dim cmd As New SqlCommand("select id,name from sports", con)


        Dim da As New SqlDataAdapter


        da.SelectCommand = cmd


        Dim table1 As New DataTable


        da.Fill(table1)


        Dim row As DataRow = table1.NewRow


        row(0) = 0

        row(1) = "Select sport"


        table1.Rows.InsertAt(row, 0)


        ComboBox1.DataSource = table1

        ComboBox1.DisplayMember = "name"

        ComboBox1.ValueMember = "id"








    End Sub


    

    Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted

        Label1.Text = ComboBox1.SelectedValue


    End Sub

End Class