vb.net数组输出 vb怎么输出数组

vb.net变成 数组组合情况输出问题

using System;

我们一直强调成都网站制作、成都做网站、外贸营销网站建设对于企业的重要性,如果您也觉得重要,那么就需要我们慎重对待,选择一个安全靠谱的网站建设公司,企业网站我们建议是要么不做,要么就做好,让网站能真正成为企业发展过程中的有力推手。专业网络公司不一定是大公司,创新互联公司作为专业的网络公司选择我们就是放心。

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication42

{

class Program

{

static void Main(string[] args)

{

count = 0;

String[] s = Console.ReadLine().Split(' ');

int[] array = new int[s.Length];

for (int i = 0; i s.Length; i++)

{

array[i] = Convert.ToInt32(s[i]);

}

int m = Convert.ToInt32(Console.ReadLine());

Listint arraylist = new Listint();

arraylist.AddRange(array);

Output(arraylist, m, null);

Console.WriteLine("共有" + count.ToString() + "个");

Console.ReadKey();

}

static int count = 0;

static void Output(Listint array, int m, Listint output)

{

if (output == null)

output = new Listint();

if (m == 0)

{

for (int i = 0; i output.Count; i++)

{

Console.Write(output[i].ToString() + " ");

}

Console.Write("\r\n");

count++;

return;

}

else

{

for (int i = 0; i array.Count; i++)

{

Listint output2 = new Listint();

output2.AddRange(output.ToArray());

output.Add(array[i]);

Listint array2 = new Listint();

array2.AddRange(array.ToArray());

for (int j = 0; j = i; j++)

{

int number = array[j];

array2.Remove(number);

}

Output(array2, m - 1, output);

output.Clear();

output.AddRange(output2.ToArray());

}

}

}

}

}

额,没注意VB,用C#写的。。。

输出了的,你新建一个C#控制台程序,把这段贴进去,运行一下就知道了

先输入一组字符串,然后输入一个整数,就会把所有的组合输出出来

我把这段转成VB再发一次吧

Module Module1

Sub Main()

count = 0

Dim s As String() = Console.ReadLine().Split(" ")

Dim array(0 To s.Length - 1) As Integer

For i As Integer = 0 To s.Length - 1

array(i) = Convert.ToInt32(s(i))

Next

Dim m As Integer = Convert.ToInt32(Console.ReadLine())

Dim arraylist As New List(Of Integer)

arraylist.AddRange(array)

Print(arraylist, m, Nothing)

Console.WriteLine("共有" + count.ToString() + "个")

Console.ReadKey()

End Sub

Sub Print(ByRef array As List(Of Integer), ByVal m As Integer, ByRef output As List(Of Integer))

If output Is Nothing Then

output = New List(Of Integer)()

End If

If m = 0 Then

For i As Integer = 0 To output.Count - 1

Console.Write(output(i).ToString() + " ")

Next

Console.Write(vbCrLf)

count = count + 1

Return

Else

For i As Integer = 0 To array.Count - 1

Dim array2 As New List(Of Integer)

Dim output2 As New List(Of Integer)

output2.AddRange(output.ToArray())

output.Add(array(i))

array2.AddRange(array.ToArray())

For j As Integer = 0 To i

Dim number As Integer = array(j)

array2.Remove(number)

Next

Print(array2, m - 1, output)

output.Clear()

output.AddRange(output2.ToArray())

Next

End If

End Sub

Dim count As Integer = 0

End Module

vb.net输出数组

1.你说的这个有点问题,是要只输出一次,也可做,

2.但问题是如果你数组还有就看不到了!这个做法有点问题

1.解决方法:

循环前面加入一个变量 dim Temp as Double=0

For i = 0 To 9

If score(i) avg and score(i)temp Then

TextBox3.Text = TextBox3.Text score(i) " "

if score(i)=avg then

temp=score(i)

end if

End If

Next

VB.net 数组怎么按任意元素的顺序排序输出

你直接传一个数组进去,而且是一个结构体数组,array.sort怎么知道根据结构中的哪一个属性进行排序?放一个c#的代码你看看,VB和C#很相似的

class Program

{

static void Main(string[] args)

{

People[] p = new People[3]

{

new People{name="张三"},

new People{name="李四"},

new People{name="张二名"}

};

//重点传一个实现了IComparer接口的类进去,告诉Array.Sort怎么排序

Array.Sort(p, new PeopleCompare());

foreach (var item in p)

{

Console.WriteLine(item.name);

}

Console.ReadKey();

}

}

//People结构体,换成类一样的

public struct People

{

public string name { get; set; }

}

//实现了IComparer接口的类

public class PeopleCompare : IComparer

{

public int Compare(object x, object y)

{

People p1 = (People)x ;

People p2 = (People)y;

return p1.name.CompareTo(p2.name);

}

}

在VB.net中,如何使几个数组变量按照列表示出来,并输出到指定的EXCEL表格中!

先在: My Project 中引用 Microsoft Excel 11.0 Object Library(这个是Excel 2003,Excel 2007 是12.0),之后在窗体代码中加入相关内容就行了。以下是一个窗体的简单实例

假设在C盘根文件夹中有:TEST.xls

Public Class 引用EXCEL窗体

Private A() As String = {"A", "B", "CC", "C", "D"}

Private B() As Integer = {1, 22, 34, 50, 16, 99, 14}

Private excelapp As New Microsoft.Office.Interop.Excel.Application

Private excelworkbook As Microsoft.Office.Interop.Excel.Workbook

Private Sub 引用EXCEL_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim Index As Integer

excelworkbook = excelapp.Workbooks.Open("c:\test.xls")

excelapp.Application.Workbooks.Add(True)

excelapp.Cells(1, 1) = "数组:A"

For Index = 0 To UBound(A)

excelapp.Cells(Index + 2, 1) = A(Index)

Next

excelapp.Cells(1, 2) = "数组:B"

For Index = 0 To UBound(B)

excelapp.Cells(Index + 2, 2) = B(Index)

Next

excelapp.Visible = True

End Sub

End Class

运行结果:

数组:A 数组:B

A 1

B 22

CC 34

C 50

D 16

99

14


本文名称:vb.net数组输出 vb怎么输出数组
文章起源:http://bzwzjz.com/article/dossgcc.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站建设公司 商城网站建设 公司网站建设 app网站建设 营销网站建设 成都网站设计 网站建设方案 成都网站制作 成都网站建设 响应式网站设计 自适应网站建设 成都网站设计 成都网站建设 网站制作公司 四川成都网站制作 成都营销网站建设 网站设计 重庆网站建设 网站设计制作 成都网站建设 成都网站设计 手机网站建设