窗體上添加3個標(biāo)簽,1個按鈕,在按鈕的單擊事件里寫代碼,如下:
成都創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供湖州網(wǎng)站建設(shè)、湖州做網(wǎng)站、湖州網(wǎng)站設(shè)計、湖州網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、湖州企業(yè)網(wǎng)站模板建站服務(wù),10余年湖州做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a(,) As Integer = {{5, 6}, {1, 3}, {8, 9}, {72, 1}, {63, 4}}
Dim Temp As Integer
Dim i As Integer
Dim j As Integer
Dim x As Integer
Dim y As Integer
'顯示排序前的數(shù)據(jù)
Label1.Text = "排序前數(shù)據(jù):" vbCrLf
For i = 0 To 4
Label1.Text = Label1.Text a(i, 0) " " a(i, 1) vbCrLf
Next
For i = 0 To 3
For j = i + 1 To 4
If a(i, 0) a(j, 0) Then
Temp = a(i, 0)
a(i, 0) = a(j, 0)
a(j, 0) = Temp
Temp = a(i, 1)
a(i, 1) = a(j, 1)
a(j, 1) = Temp
End If
Next
Next
'顯示排序前的數(shù)據(jù)
Label2.Text = "排序后數(shù)據(jù):" vbCrLf
For i = 0 To 4
Label2.Text = Label2.Text a(i, 0) " " a(i, 1) vbCrLf
Next
'把第3行元素賦予X,Y
x = a(2, 0)
y = a(2, 1)
'輸出X,Y
Label3.Text = "X=" x vbCrLf "Y=" y
End Sub
數(shù)組好像沒有快速賦值吧,或者你再把問題再清楚一點。
語句執(zhí)行時間倒是可以做到。在語句前
Dim oldTime As Date = Now
在過程語句后加
Dim newTime As Date = Now
Dim differenceInSeconds As Long = DateDiff(DateInterval.Second, oldTime, newTime)
textbox1.text= "共用了:" differenceInSeconds "秒!"
vb.net已經(jīng)去掉了控件數(shù)組這個類,不過有個代替該方式的一個屬性:Tag,你可以把這些關(guān)聯(lián)的Tag屬性設(shè)置為同一標(biāo)記,如:a。然后遍歷所有的checkbox并且tag為a的則選定:Protected Sub chkAll_Click() For Each ctl As Control In Me.Controls ''如果checkbox在一個容器里,比如groupbox,那可以用groupbox.controls
If ctl.GetType().Name.ToLower() = "checkbox" Then
CType(ctl, CheckBox).Checked = CheckBox3.Checked
End If
NextEnd Sub
for i = 0 to 3
textbox_未知.text = a(i,1) a(i,2) a(i,3) a(i,4) vbcrlf
next
如果我吧長寬弄反了自行轉(zhuǎn)正,
如果要間隔,請插入 VBtab
參考
#includestdio.h
int main()
{int n,i,j,t,a[200];
printf("數(shù)組中數(shù)的個數(shù):");
scanf("%d",n);
printf("數(shù)組中的數(shù):\n");
for(i=0;in;i++)
{
a[i]=i+1;
printf("%d ",a[i]);
}
for(i=0,j=n-1;ij;i++,j--)
{t=a[i];a[i]=a[j];a[j]=t;}
printf("\n逆序后的數(shù)組:\n");
for(i=0;in;i++)
printf("%d ",a[i]);
printf("\n");
getch();
return 0;
}