Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Im having a hardtime to pass a parameter to below line.


'myEncoderParameter = New EncoderParameter(myEncoder, CType(20L, Int32))
      myEncoderParameter = New EncoderParameter(myEncoder, CType(xx, Int32))



Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim xx As System.Int64
    xx = 20 & "L"
    Try
        If Not IO.Directory.Exists("C:\Folder\") Then IO.Directory.CreateDirectory("C:\Folder\")
        'Dim bit As Bitmap = CaptureScreen(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
        Dim myImageCodecInfo As ImageCodecInfo
        Dim myEncoder As Encoder
        Dim myEncoderParameter As EncoderParameter
        Dim myEncoderParameters As EncoderParameters

        Dim bit As Bitmap = CaptureScreen(0, 0, Screen.AllScreens.Sum(Function(s As Screen) s.Bounds.Width), Screen.AllScreens.Max(Function(s As Screen) s.Bounds.Height))

        myImageCodecInfo = GetEncoderInfo(ImageFormat.Jpeg)
        myEncoder = Encoder.Quality
        myEncoderParameters = New EncoderParameters(1)
        'myEncoderParameter = New EncoderParameter(myEncoder, CType(20L, Int32))
        myEncoderParameter = New EncoderParameter(myEncoder, CType(xx, Int32))

        'myEncoderParameter = New EncoderParameter(myEncoder, Fix(EncoderValue.CompressionLZW))
        myEncoderParameters.Param(0) = myEncoderParameter
        'myBitmap.Save("Shapes025.jpg", myImageCodecInfo, myEncoderParameters)
        bit.Save("C:\Folder\" & Format(Now, "yyyyMMdd hhmmss") & ".jpg", myImageCodecInfo, myEncoderParameters)
        bit.Dispose()
    Catch
        If Err.Number = "-2147467261" Then
            Exit Sub
        End If
    End Try
End Sub


What I have tried:

'myEncoderParameter = New EncoderParameter(myEncoder, CType(20L, Int32))
myEncoderParameter = New EncoderParameter(myEncoder, CType(xx, Int32))
Posted
Updated 20-Apr-18 9:59am

1 solution

What is the point to create an int64 variable if you already know that you will need an int32 value?
Have you tried:
VB.NET
Dim xx As Integer = 20
'' ...
myEncoderParameter = New EncoderParameter(myEncoder, xx)

If you really want to define an int64 in the first place, you should know that VB.NET does not use suffixes, as you can do in C#.
This would give somehing like:
VB.NET
Dim xx as Int64 = 20

This seems that you are trying to convert a code from C# to VB.NET without having a clear understanding of both languages and their differences; that's not a good idea :)
Kindly.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900