Hi
I am getting error - Type mismatch on below line
picoriginal.Picture = ("c:\image.jpg")
Dim picoriginal As PictureBox
Call SaveImageFromAPI(apiUrl, UsrName, Pword, tno, picoriginal)
Public Sub SaveImageFromAPI(apiUrl As String, UserName As String, Pwd As String, TrNo As String, picoriginal As PictureBox)
picoriginal.Picture = ("c:\image.jpg")
Thanks
Daniel WrightPosted Mar 20, 2025, 1:13 PM
It looks like the error you are encountering is a Type mismatch. In Visual Basic, a Type mismatch error typically occurs when you try to assign a value of one data type to a variable of another incompatible data type.
In your code snippet, the line causing the issue is:
picoriginal.Picture = ("c:\image.jpg")The error stems from attempting to assign a string value ("c:\image.jpg") to
picoriginal.Picture, which is likely expecting a different type of value to represent an image.To resolve this error, you need to ensure that the data type of the value you are trying to assign matches the expected data type for
picorignal.Picture. In the case of setting the picture of a PictureBox object, typically you would need to use an image file or object that the PictureBox control can work with.Here's an example of how you can load an image file into a PictureBox in VB.NET:
By using the `Image.FromFile` method, you can load an image file into the PictureBox control. This way, you provide the PictureBox with the correct data type (an Image object) instead of a string, avoiding the Type mismatch error.
I hope this explanation helps you resolve the Type mismatch error in your code. Let me know if you need further assistance or have any more questions!