我有一个名为BuyShares()的方法,它应该在文本框中获取一个值并为其添加另一个用户输入值。我想使用一个消息框,用户通过单击“确定”来设置方法。唯一的问题是我似乎无法调用该方法。 这是方法。
public void BuyShares(int anAmount)
{
int newShares;
newShares = GetInvestmentShare() - anAmount;
SetInvestmentShare(newShares);
}
这是我设置的消息框
private void button1_Click(object sender, EventArgs e)
{
DialogResult result;
result = MessageBox.Show("Your transaction is complete", "Success", MessageBoxButtons.OK);
if(result==DialogResult.OK)
{
txtStockSharesTab3.Text=??????
}
这是一个Windows窗体应用程序,该程序有几个不同的类
答案 0 :(得分:0)
没有给出答案,因为你可能想从中学到一些东西......
我猜你想从一个文本框中获取要购买的股票数量,然后调用BuyShares
并最终将txtStockSharesTab3
更新为此值。
您的BuyShares
方法返回void
,表示它不会返回值。在该方法的某个位置,您将更新txtStockSharesTab3
文本框。是否需要BuyShares
的确切方法签名?