'Open
New Project. Add Module and put this code on it. Declare Function SetVolumeLabel Lib "kernel32" Alias "SetVolumeLabelA" (ByVal lpRootPathName As String, ByVal lpVolumeName As String) As Long Public Function ChangeLabel(mDrive As String, mNewLabel As String) As Integer ChangeLabel = SetVolumeLabel(mDrive, mNewLabel) End Function 'Add 1 button , 2 label, 1 text box and 1 drive component. 'Write down the codes below in the form. Private Sub Command1_Click() Dim t As String Dim c As String c = Trim(Text1.Text) If Not c = "" Then t = Left(Drive1.Drive, 2) & "\" If ChangeLabel(t, c) = 0 Then MsgBox "Fail change the volume label on that drive ", , "Warning" Else MsgBox "Now the volume label of drive " & t & " is " & Text1.Text, , "Message" End If End If End Sub Private Sub Form_Load() Label1.Caption = "New Volume Label" Label2.Caption = "Drive " Text1.Text = "" Command1.Caption = "Set Volume Label" End Sub
|