vb.net CDate实例代码
时间: 2024-01-02 12:04:59 浏览: 179
下面是一个使用 VB.NET 中的 CDate 函数的示例代码:
```
Dim dateString As String = "9/1/2021"
Dim dateValue As DateTime = CDate(dateString)
Console.WriteLine(dateValue.ToString())
```
在此示例中,我们创建了一个字符串 dateString,表示日期为 2021 年 9 月 1 日。然后,我们使用 CDate 函数将该字符串转换为 DateTime 类型,并将其存储在 dateValue 变量中。最后,我们使用 ToString 方法将 dateValue 转换为字符串,并将其输出到控制台。输出将是 "9/1/2021 12:00:00 AM",因为 CDate 函数将字符串转换为 DateTime 对象,并默认将时间设置为午夜 12 点。
阅读全文
相关推荐
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)