You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS2019中Visual Basic移除窗体默认边框后自定义关闭按钮报错求助

Hey there, let's tackle this error you're seeing. That "Property access must assign to the property or use its value" message usually pops up when the compiler thinks you're trying to access a property (not a method) — and here's why it's happening after removing the default form border:

Most likely, you've accidentally created a naming conflict with the Close method of the Form class. When you removed the default border and started building custom UI elements, you might've defined something (like a property, variable, or even a custom button named Close) that's overriding the built-in Close() method. The compiler now sees Me.Close as that property instead of the method to shut down the form.

Here's how to fix it:

  • Do a quick search in your form's code for any instances where you've declared something named Close. For example, if you have a line like Public Property Close As Boolean or a button accidentally named just Close, rename that item to something unique — like IsClosePending or btnCustomClose.
  • Once you rename the conflicting member, Me.Close() will work just like it did before, since the compiler will now reference the Form's built-in method again.

2. Explicitly call the base class method (if you don't want to rename)

If for some reason you need to keep the conflicting name, you can tell the compiler to use the base Form class's Close method directly:

MyBase.Close()

Drop that line into your custom close button's Click event, and it'll bypass any custom properties/variables named Close in your form.

Quick example of a working custom close button

Here's what your button click handler should look like once the conflict is fixed:

Private Sub btnCustomClose_Click(sender As Object, e As EventArgs) Handles btnCustomClose.Click
    ' This will properly close the form now
    Me.Close()
    ' Or use MyBase.Close() if you kept the conflicting name
End Sub

Just double-check that your form's FormBorderStyle is set to None (you probably already did this, but it's worth confirming to ensure your custom UI behaves as expected).

内容的提问来源于stack exchange,提问作者Crann Moroney

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 07:57:53