Conversion from string "C: \ Mediamemebuilderpro \ MDAL1Imag" to input "Double" is not valid.

I started a new application and every 30 seconds it will save the image to a temporary directory, but I need to save each photo with a different name like MDAL1Image1.jpg, MDAL1Image2.jpg, etc., but I get this error

{"Conversion from string "C:\Mediamemebuilderpro\MDAL1Imag" to type 'Double' is not valid."}

      

This is the line where I am getting the error

PB1.Save("C:\Mediamemebuilderpro\" + "MDAL1Image" + nametosave + ".jpg", System.Drawing.Imaging.ImageFormat.Bmp)
    timetosavetemp = 0

      

This is the code I got the error

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
    timetosavetemp = timetosavetemp + 1
    If timetosavetemp >= 30 Then
        Dim nametosave = 1
        nametosave = nametosave + 1
        Dim PB1 As New Bitmap(PictureBox1.Image)

        PB1.Save("C:\Mediamemebuilderpro\" + "MDAL1Image" + nametosave + ".jpg", System.Drawing.Imaging.ImageFormat.Bmp)
        timetosavetemp = 0

    End If
End Sub

      

+3


source to share


1 answer


create a filename with String.Format

, changing the segments as needed.

Dim filename As String = "MDAL1Image" 'Change as needed
Dim path As String = String.Format("C:\Mediamemebuilderpro\{0}{1}.jpg", filename, nametosave)
PB1.Save(path, System.Drawing.Imaging.ImageFormat.Bmp)

      



When used, ... "MDAL1Image" + nametosave + ...

it tries to perform a binary operation on nametosave

, which is double, and "MDAL1Image"

which is a string. It cannot interpret the string as a valid double value.

+3


source







All Articles