问题描述
所以,我遇到了一些问题.
So, I am having some issues.
创建一个查找两个城市之间行驶距离的项目.使用两个包含城市名称的下拉列表.标记一个列表出发和另一个目的地.使用查找按钮计算距离.
Create a project that looks up the driving distance between two cities. Use two drop-down lists that contain the names of the cities. Label one list Departure and the other Destination. Use a Look Up button to calculate the distance.
int[,] miles =
{
{0, 1004, 1753, 2752, 3017, 1520, 1507, 609, 3115, 448},
{1004, 0, 921, 1780, 2048, 1397, 919, 515, 2176, 709},
{1753, 921, 0, 1230, 1399, 1343, 517, 1435, 2234, 1307},
{2752, 1780, 1230, 0, 272, 2570, 1732, 2251, 1322, 2420},
{3017, 2048, 1399, 272, 0, 2716, 1858, 2523, 1278, 2646},
{1520, 1397, 1343, 2570, 2716, 0, 860, 1494, 3447, 1057},
{1507, 919, 517, 1732, 1858, 860, 0, 1307, 2734, 1099},
{609, 515, 1435, 2251, 2523, 1494, 1307, 0, 2820, 571},
{3155, 2176, 2234, 1322, 1278, 3447, 2734, 2820, 0, 2887},
{448, 709, 1307, 2420, 2646, 1057, 1099, 571, 2887, 0}
};
combo txtDeparture 已经通过items属性填充了城市列表
combo txtDeparture has been filled with the list of cities through the items property
combo txtDestination 已经通过 items 属性填充了城市列表
combo txtDestination has been filled with the list of cities through the items property
推荐答案
如果组合框中的项目对应于 2D 数组,您可能想要这样做:
If the item in the comboboxes correspond to the 2D array you would want to do something like this:
var distance = miles[combotxtDeparture.SelectedIndex, combotxtDestination.SelectedIndex];
这篇关于Visual Basic 中的数组 创建处理行驶距离的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!