I am attempting to randomly generate a picture from a folder but am having issues with file extensions. All pictures are named integers for simplification (1-19 at the moment).
Code:
Private Sub Form_Load()
Dim thepic As Integer, themax As Integer, fso As Object, filecount As Integer, picstr as String
Screen.ActiveForm.Painting = False
Set fso = CreateObject("Scripting.FileSystemObject")
folderspec = "S:\Shared\Warranty Returns\WRA Data Storage\Backups\Files\Pictures"
If fso.FolderExists(folderspec) Then
themax = fso.getfolder(folderspec).files.Count
thepic = Int((themax - 1 + 1) * Rnd + 1)
picstr = fso.getfolder(folderspec).files.Items(thepic).name
Me.imgpic.Picture = "S:\Shared\Warranty Returns\WRA Data Storage\Backups\Files\Pictures\" & picstr
End If
finish:
Screen.ActiveForm.Painting = True
End Sub
The bolded section is where I am getting tripped up and can't seem to find the correct code to find this property. I just want to grab the ".jpg" or ".png" portion of the name