Click here to Skip to main content
15,612,080 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Private Sub Timer30_Tick(sender As Object, e As EventArgs) Handles Timer30.Tick
Second = Second + 1
        If Second >= 30 Then
            MessageBox.Show("Time Up ")
        End If
            Dim ScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
            Dim BMP As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
            Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP)
            g.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)
        Dim DirectoryA As String = FileDirectory.Text
        Dim Frame1 As String = FileNumber.Text
        Dim img1 As String = FileType.Text
        FileNumber.Text = FileNumber.Text + 1 'i am getting errors at this point
                          'Conversion from string "" to type 'Double' is not valid.

BMP.Save(DirectoryA & Frame1 & img1)
Updated 17-Feb-15 21:05pm
[no name] 18-Feb-15 1:51am    
You wanted to convert "" ? or replace the ""?
Srikanth59 18-Feb-15 2:32am    
i want to convert into string format into double as error showed
Sergey Alexandrovich Kryukov 18-Feb-15 2:43am    
If your input is "!@@$@$^%@!@#!", what is the "converted" double value should be? :-)
Srikanth59 18-Feb-15 3:59am    
am getting errors
A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll

Additional information: Conversion from string "" to type 'Double' is not valid.

make sure the source type is convertible to the destination type.
Sergey Alexandrovich Kryukov 18-Feb-15 10:58am    
Sure. Did you understand my comment you replied to?

1 solution

You're trying to convert text to numeric value:
FileNumber.Text = FileNumber.Text + 1

Instead of it, use this:
'on the beginning of the function
Dim counter As Integer = 0
If Int32.TryParse(FileNumber.Text, counter) Then
    FileNumber.Text = counter.ToString()
End If

For further information, please see: Int32.TryParse Method (String, Int32)[^]
Share this answer
Sergey Alexandrovich Kryukov 18-Feb-15 2:44am    
Sure, a 5.
Maciej Los 18-Feb-15 3:04am    
Thank you, Sergey ;)
Srikanth59 18-Feb-15 5:06am    
i tried above code but it doesn't display any information in the textbox and it just shows me nothing when i executed
Maciej Los 18-Feb-15 5:39am    
Debug the code and find out why it happens.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

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