ابتدا فضای نام Imports System.Management را وارد کنید سپس یک کنترل
Textbox , button تعریف کنید
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim HDinformation As New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
Dim HD As ManagementObject
For Each HD In HDinformation.Get()
If i = 1 Then
Exit Sub
End If
TextBox1.Text = TextBox1.Text & " " & HD("SerialNumber").ToString()
i = i + 1
Next
End Sub
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Enter)
{
SendKeys.Send("{tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
Try
Me.TextBox1.Text = Format(CLng(Me.TextBox1.Text), "###,###,###,###,###;;0")
Me.TextBox1.SelectionStart = Me.TextBox1.Text.Length
Catch
Exit Try
End Try
End Sub