声明变量和Val函数 [英] declaration variable and Val functions
本文介绍了声明变量和Val函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
vb识别声明变量(Dim)和Val函数存在问题
there is a problem with vb recognizing declaration variable (Dim) and Val functions
我找不到任何有效的东西
i havent found anything that works
推荐答案
您好,
如果没有看到您的代码我们无法访问,但会说您需要在类,子或函数中使用Dim但不在这些之外。
Without seeing your code we can't access but will say you need to use Dim in a class, sub or function but not outside of these.
不正确
这是一个有效的简单示例
This is a simple example that works
Namespace Demo
Public Class Hello
Public Sub ThisWorks()
Dim ThisWillNotWork As Integer = 0
End Sub
End Class
End Namespace
关于Val使用TryParse,这里是Double,同样适用于DateTime,Integer,Decimal
In regards to Val use TryParse, here is for Double, same applies for DateTime, Integer, Decimal
Dim d As Double = 0
Dim value As String = "9.0"
If Double.TryParse(value, d) Then
MessageBox.Show("Valid")
Else
MessageBox.Show("Invalid")
End If
这篇关于声明变量和Val函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文