我需要取前 5 个字符,以便它们与我早期保存的同名图片框匹配。
例如,此文件名可以是 12345_Text_Text_Text.pdf
Dim key As String = Path.GetFileNameWithoutExtension(e.Name)
Dim p As PictureBox = CType(Me.Controls(key), PictureBox)
p.Image = My.Resources.Ok
我认为这样做会奏效;
Dim subkey As String
Dim key As String = Path.GetFileNameWithoutExtension(e.Name)
subkey = Left(key, 5)
问题似乎是Left
命令,Public Property Left As Integer' has no parameters and its return type cannot be indexed.
完整的子程序在这里;
Private Sub Watcher_Changed(ByVal sender As Object, ByVal e As FileSystemEventArgs) Handles Watcher.Changed
Dim key As String = Path.GetFileNameWithoutExtension(e.Name)
Dim subkey As String
subkey = Left(key, 5)
Dim p As PictureBox = CType(Me.Controls(key), PictureBox)
p.Image = My.Resources.Ok
End Sub
关于我做错了什么的建议?