我有两个小时要交的项目,但我听不懂指示 [英] I have a project due in two hours but i cant make sense of the instructions

查看:80
本文介绍了我有两个小时要交的项目,但我听不懂指示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务如下:

在 表单加载事件,其数字从0到10.标签将以"???"开头在其中.您将编写一个函数   接受一个String参数和一个列表框参数,该参数计算String在 列表框 span>   返回该值.  

"Write a visual basic program that has two list boxes a button. a textbox and a label.  The first list box will have each letter of your first and last names as a separate list item.  The second list box will be filled by a For loop in the form load event with the numbers from 0 to 10.  The label will start with "???" in it.  You will write a function that takes a String parameter and a list box parameter that counts how many times the String occurs in the listbox and returns that value .  

  • 文本框 列表框
  • 如果您从数字列表框中选择一个数字,则应选择该位置的字母
  • 如果您从列表框中选择一个带有您姓名的字母,则应将其删除."
  • When the button is pressed, the button click event should call the function on the text in the textbox and the listbox with your name in it and put the result in an integer variable named letterCount.
  • The the button click event will put the value of letter count into the label.
  • If letter count is one of the numbers in the number list box then the event should select it.
  • If letter count is 0 then the event should place the text in the textbox at the end of the listbox with your name in it.
  • If you select a number from the number list box it should select the letter at that position in the list box with your name in it.
  • If you select a letter from the list box with your name in it it should delete it."

我并没有要求任何人向我介绍如何执行此操作的代码(尽管这样做会很有帮助).我根本不明白我在问什么?我已经尝试过问我的教授,但他拒绝详述.到目前为止,我所拥有的只是按钮, 文本框,两个列表框和一个标签.

I'm not asking for anyone to present me code on how to do this (although that would be most helpful). I simply don't understand what's being asked of me? I've already tried asking my professor but he refuses to elaborate. So far all I have is the button, textbox, two list boxes, and a label.

推荐答案

到目前为止,我所拥有的只是按钮,文本框,两个列表框和一个标签.

So far all I have is the button, textbox, two list boxes, and a label.

字母"列表框需要使用字母列表进行初始化.这是在设计器中完成的,方法是选择列表框,然后在属性"窗格中单击项目"属性的下拉列表,然后输入字母.

The Letter listbox needs to be initialized with the list of letters.  This is done in the designer by selecting the listbox then clicking the dropdown for the Items property in the Properties pane, and entering the letters.

通过在0到10的循环中添加项目,将在表单加载事件中初始化数字"列表框.请参见:
https://msdn.microsoft .com/en-us/library/system.windows.forms.listbox.objectcollection.add(v = vs.110).aspx

The Number list box will be initialsed in the form load event by adding items in a loop from 0 to 10. See:
https://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.objectcollection.add(v=vs.110).aspx

请注意,您将向数字列表框项目集合添加一个整数,但它将显示为字符串.

Note that you will add an Integer to the Number listbox items collection, but it will display as a String.

可以使用"???"来初始化标签使用属性窗口中的文本"属性.

The label can be initialized with "???' using the Text property in the properties window.

现在您需要创建函数.功能签名是

Now you need to create the function.  The function signature is

 公共函数名称(arg1作为字符串,arg2作为ListBox)作为整数

  Public Function name(arg1 As String, arg2 As ListBox) As Integer

该函数中的代码将遍历列表框(arg2)项集合,检测该项是否与字符串(arg1)相匹配,并为每个匹配项在计数器上加1.该函数的返回值是计数器.
请参阅: https://msdn.microsoft.com/en-us/library/sect4ck6.aspx

The code in the function will iterate over the listbox (arg2) Items collection, detecting if the item matches the string (arg1) and adding 1 to a counter for each match.  The return value of the function is the counter.
See: https://msdn.microsoft.com/en-us/library/sect4ck6.aspx

到此为止,应该可以使用文字(例如's'和数字listbox  name)在按钮单击事件处理程序中添加对该函数的调用,以便您可以看到该函数正常工作.

When you get that far it should be possible to add a call to the function in your button click event handler, using literals (eg, 's' and the number listbox name), so that you can see that the function works properly.



这篇关于我有两个小时要交的项目,但我听不懂指示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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