X = x + 1的VBA速记吗? [英] VBA shorthand for x=x+1?

查看:69
本文介绍了X = x + 1的VBA速记吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sub btn1_Click()
Static value As Integer
value = value + 1
MsgBox value
End Sub

我发誓,当我在大学里上VB.net课程时,有一种较短的方法来告诉变量在其自身上添加".也许x = + 1.我现在正在使用Access,而不是Visual Studio.当我尝试在VBE中删除+时.我什至删除了Option Explicit并保持不变

I swear when I was taking a VB.net course in college there was a shorter way to tell a variable to add '' to itself. Maybe x=+1. I am using Access now though instead of visual studio. When I try that within the VBE it removes the +. I even removed Option Explicit with no change

假设答案是否定的,则没有办法将其简写为& ;;它只是VBA特有的

Assuming the answer will be no, there is no way to short-hand it & its just a peculiarly of VBA

推荐答案

遗憾的是,VBA中没有operation-assignment运算符.

Sadly there are no operation-assignment operators in VBA.

(VB.Net中提供了附加分配+=等)

(Addition-assignment += et al are available in VB.Net)

毫无意义的解决方法;

Pointless workaround;

function Inc(ByRef i As Integer)
   i = i + 1  
end function
...
Static value As Integer
inc value
inc value

这篇关于X = x + 1的VBA速记吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆