如何解决从字符串“转换”的转换输入'Double'无效。 [英] how to solve Conversion from string "" to type 'Double' is not valid.
本文介绍了如何解决从字符串“转换”的转换输入'Double'无效。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Private Sub Timer30_Tick(sender As Object, e As EventArgs) Handles Timer30.Tick
Second = Second + 1
If Second >= 30 Then
Timer30.[Stop]()
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)
推荐答案
您正在尝试将文本转换为数值:
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
'later
If Int32.TryParse(FileNumber.Text, counter) Then
counter+=1
FileNumber.Text = counter.ToString()
End If
如需了解更多信息,请参阅:< a href =https://msdn.microsoft.com/en-us/library/f02979c7%28v=vs.110%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet- 1> Int32.TryParse方法(字符串,Int32) [ ^ ]
这篇关于如何解决从字符串“转换”的转换输入'Double'无效。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文