public structure struc
目前成都创新互联已为成百上千的企业提供了网站建设、域名、虚拟空间、成都网站托管、企业网站设计、龙湾网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
public name as string
public shengao as integer
……
end structure
public items as struc()
readonly property people(argname as string) as struc
get
for each i as struc in items
if i.name=argname then reture i
next
end get
end property
struc可以用class,property可以用function,people通过参数返回一个对象,对象可以来源于某个数组的某个元素,也可以是其他来源。
people也可以是类的构造方法,而shengao等是类的成员,但你的写法是错误的,构造方法必须用new实例化
很简单,在end select前再多加一种情况case else return "XXXx",因为你只提供了0-9这10种情况
Public Function Zuhe(ByVal qa As String) As String
Select Case qa
Case "0"
Return "1"
Case "1"
Return "3"
Case "2"
Return "4"
Case "3"
Return "6"
Case "4"
Return "2"
Case "5"
Return "8"
Case "6"
Return "9"
Case "7"
Return "7"
Case "8"
Return "5"
Case "9"
Return "0"
Case else
Return "XXXX"
End Select
End Function
注意:参数为动态数组;
Private Function MyF(ByRef d() As Integer)
ReDim d(4, 13) As Integer
Dim i As Integer
Dim j As Integer
Dim n As Integer
Dim MyNum(4) As Integer
For i = 1 To 4
MyNum(i) = 0
Next i
Randomize
For i = 1 To 4
For j = 1 To 13
n = Int(Rnd * 4 + 1)
Do While MyNum(n) = 13
n = Int(Rnd * 4 + 1)
Loop
d(i, j) = n
MyNum(n) = MyNum(n) + 1
Next j
Next i
End Function
不熟悉VB,如有不妥的地方请包涵!
Public Class Stack
Dim aryData() As Integer
Sub New(ByVal Num As Integer)
Dim aryData(Num) As Integer
End Sub
Function Pop() As Integer
If (aryData.Length = 0) Then
Return 0
Else
Dim a As Integer
a = aryData(aryData.Length)
aryData(aryData.Length) = Convert.ToInt32(DBNull.Value)
Return a
End If
End Function
Sub Push(ByVal n As Integer)
For Each i As Integer In aryData
If (aryData(i) = Convert.ToInt32(DBNull.Value)) Then
aryData(i) = n
End
Else
Continue For
End If
Next
End Sub
Sub PrintStack()
For Each i As Integer In aryData
If (aryData(i) = Convert.ToInt32(DBNull.Value)) Then
End
Else
Print(aryData(i))
End If
Next
End Sub
End Class
public function createstringarr() as string()
return new string(){"d1","d2","d3","d4"}
end function
首先在窗体上添加Button1,ListBox1,下面是完整代码
Public Class Form1
Public Sub BubbleSort(ByVal arr() As Integer) '冒泡法排序
Dim temp As Double
Dim i, j As Integer
For i = 0 To arr.GetUpperBound(0) - 1
For j = i + 1 To arr.GetUpperBound(0) - 1
If arr(i) arr(j) Then
temp = arr(j)
arr(j) = arr(i)
arr(i) = temp
End If
Next
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '调用
Dim arr() As Integer = {55, 22, 33, 11, 77, 88}
BubbleSort(arr) '调用排序过程
Me.ListBox1.Items.Clear()
For i = 0 To arr.GetUpperBound(0) - 1 '显示排序后结果
Me.ListBox1.Items.Add(arr(i).ToString)
Next
End Sub
End Class