vb.net课后例题实例的简单介绍

关于VB.NET进度条的实例

该实例有很多实现方法,下面介绍一种不同的给你:

创新互联公司提供高防物理服务器租用、云服务器、香港服务器、四川雅安服务器托管

首先要在窗体中载入以下控件:progressbar(进度条),label(用来实时显示文本提示),两个timer(分别控制进度条进度的增减),然后用以下代码就能实现:

Public Class Form1

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

Timer1.Enabled = True

Timer1.Interval = 500

Timer2.Interval = 500

ProgressBar1.Value = 0

ProgressBar1.Maximum = 100

ProgressBar1.Minimum = 0

End Sub

'上述过程是设置控件的初始值,也可以在属性面板设置

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

ProgressBar1.Value += 1

Label1.Text = "当前完成" ProgressBar1.Value "%"

If (ProgressBar1.Value = 100) Then

Timer1.Enabled = False

Timer2.Enabled = True

End If

End Sub

'timer1用来控制进度的增加

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

ProgressBar1.Value -= 1

Label1.Text = "当前完成" ProgressBar1.Value "%"

If (ProgressBar1.Value = 0) Then

Timer1.Enabled = True

Timer2.Enabled = False

End If

End Sub

'time2用来控制进度的减少

End Class

VB.net实例

1 生成txt文件。

DimSaveFileDialog1AsNewSaveFileDialog() '创建一个保存对话框

SaveFileDialog1.Filter ="txt files (*.txt)|*.txt" '设置扩展名

IfSaveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OKThen '如果确定保存

My.Computer.FileSystem.WriteAllText(SaveFileDialog1.Filename, Textbox1.Text,False) '保存文本,False表示不追加文本,直接覆盖其内容

EndIf

原文链接:

用vb.net设计程序,打印九九乘法表的右上部分和右下部分

右上部分的:

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

Dim se$, i%, j%

Label1.Text = Space(35) "九九乘法表" vbCrLf

Label1.Text = Space(35) "_________" vbCrLf

For i = 1 To 9

For j = 1 To 9

If j = i Then

se = i "×" j "=" i * j

Label1.Text = se Space(8 - Len(se))

Else

se = ""

Label1.Text = se Space(9 - Len(se))

End If

Next j

Label1.Text = vbCrLf

Next i

End Sub

左下部分的:

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

Dim se$, i%, j%

Label1.Text = Space(35) "九九乘法表" vbCrLf

Label1.Text = Space(35) "_________" vbCrLf

For i = 1 To 9

For j = 1 To i

se = i "×" j "=" i * j

Label1.Text = se Space(8 - Len(se))

Next j

Label1.Text = vbCrLf

Next i

End Sub


分享文章:vb.net课后例题实例的简单介绍
本文网址:http://scyanting.com/article/hjiocp.html