icemail
12-25-2019, 07:03 AM
Hello i try to open picture in userform2.imagebox .All picture names like "0001" format in folder. Expectation is "0001" output is "1"
randno = 0
randno = Int((1000 - 2 + 2) * Rnd + 2)
If Len(randno) = 1 Then
fname = CStr("\" & "000" & randno & "-" & Lg & ".jpg")
ElseIf Len(randno) = 2 Then
fname = CStr("\" & "00" & randno & "-" & Lg & ".jpg")
ElseIf Len(randno) = 3 Then
fname = CStr("\" & "0" & randno & "-" & Lg & ".jpg")
ElseIf Len(randno) = 4 Then
fname = CStr("\" & "" & randno & "-" & Lg & ".jpg")
End If
With Img
Path1 = "C:\Downloads\Lg\"
myfile = Path1 & Lg & fname
.Picture = LoadPicture(myfile)
End With
randno = 0
randno = Int((1000 - 2 + 2) * Rnd + 2)
If Len(randno) = 1 Then
fname = CStr("\" & "000" & randno & "-" & Lg & ".jpg")
ElseIf Len(randno) = 2 Then
fname = CStr("\" & "00" & randno & "-" & Lg & ".jpg")
ElseIf Len(randno) = 3 Then
fname = CStr("\" & "0" & randno & "-" & Lg & ".jpg")
ElseIf Len(randno) = 4 Then
fname = CStr("\" & "" & randno & "-" & Lg & ".jpg")
End If
With Img
Path1 = "C:\Downloads\Lg\"
myfile = Path1 & Lg & fname
.Picture = LoadPicture(myfile)
End With