用VB怎样为图片更名

来源:百度知道 编辑:UC知道 时间:2024/05/26 19:51:09
每天用数码相机拍产品样品照片,我想用VB做个小程序:用drivelistbox+dirlistbox+filelistbox+image预览图片,另一textbox显示图片名称(数码相机自动命名),我怎样才能实现用扫描器扫描到样品条码的名称替代textbox的图片名的同时也用该名称重命名该图片,并自动跳入下一张图片重复上一操作?

窗体上有drivelistbox,dirlistbox,filelistbox,textbox,Picturebox,试过了可行!
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = "c:\"
File1.Path = Dir1.Path
End Sub

Private Sub File1_Click()
On Error GoTo e
Text1.Text = File1.List(File1.ListIndex)
Text1.SetFocus
Text1.SelLength = Len(Text1.Text)
Picture1.Picture = LoadPicture(Dir1.Path & "\" & File1.List(File1.ListIndex))
e:
Select Case Err.Number
Case 481
Picture1.Cls
Picture1.Print "无效图片"
If File1.ListIndex < File1.ListCount Then File1.ListIndex = File1.ListIndex + 1
End Select
End Sub

Private Sub Form_Load()
Text1.Text = ""
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim OldName As String
If KeyCode = vbKeyReturn Then
OldName = Dir1.Path & "\"