Visual Studio 2013,错误“表达式必须具有类类型”

时间:2021-04-25 17:05:01

I create an project with Visual Studio--C++--CLR, and I am trying to create a small login page which have two textbox and two label and button like everyone else.

我使用Visual Studio - C ++ - CLR创建了一个项目,我正在尝试创建一个小的登录页面,其中包含两个文本框和两个标签以及其他所有人的按钮。

After I put everything I am trying to put some code in button "login" like this

在我把所有的东西放在我试图把一些代码放在按钮“登录”之后

string str = userNameInput.Text;  // userNameInput is a textBox

and it shows me an error "Expression must have a class type"

它显示了一个错误“表达式必须具有类类型”

Can anyone explain how this happened?

谁能解释这是怎么发生的?

1 个解决方案

#1


It seems like userNameInput is pointer. The error implies that it is and your line should be: userNameInput->Text

似乎userNameInput是指针。该错误意味着它是,您的行应该是:userNameInput-> Text

#1


It seems like userNameInput is pointer. The error implies that it is and your line should be: userNameInput->Text

似乎userNameInput是指针。该错误意味着它是,您的行应该是:userNameInput-> Text