visual-studio - 将月份添加到给定日期
问题描述
我想将用户给定的月数(例如 2)添加到给定的日期,但我遇到了同样的困难。我试过了
Public Function MyFunction(m_GMonths As Double, m_Given_Date as Date) As Double
Return m_Given_Date + m_GMonths
End Function
我得到的错误是Operator '+' is not defined for types 'Date' and 'Double'
有人可以告诉我我做错了什么吗?
解决方案
你应该使用AddMonths
:
Dim z = DateTime.Now
Dim x = z.AddMonths(2)
推荐阅读
- python - 在 Google Colab 中从 GitHub 加载 .zip 文件
- python - 如何在 PRAW 中找到 Redditor 的名称?
- html - 如何在不创建 N 的情况下在 CSS 动画中获得 N 点?
- python - 无法显示 .xml 文件的标签名称(返回 None )
- javascript - 简单的货币转换器
- typescript - Aurelia 2 全局窗口变量
- ruby-on-rails - Nokogiri 使用“渲染”解析(执行的)视图文件的替代方法
- php - 如何使用php分隔excel中带逗号的全名
- javascript - 使用 axios 访问谷歌图片搜索 API 时出现错误请求
- postgresql - 为什么设置“POSTGRES_HOST_AUTH_METHOD”不起作用?