引用 | 编辑
ebolaman
2014-01-06 14:52 |
1楼
▲ ▼ |
||||||||||
有
只要设定 ProgressBar 属性 Style=Marquee 复制程式 .Style = ProgressBarStyle.Marquee 复制程式 .Style = ProgressBarStyle.Continuous 另外 Marquee style 的移动速度可以调整属性 MarqueeAnimationSpeed 参考 MSDN http://msdn.microsoft.com/en-us/library/system.windows.forms.progressbar.style.aspx 仿 Chrome 安装程式范例: 复制程式 Public Class Form1 ReadOnly tlpForm As New TableLayoutPanel ReadOnly lblSetup As New Label ReadOnly prgSetup As New ProgressBar ReadOnly timerPrg As New Timer Private Sub Form1_Load() Handles MyBase.Load With Me .Text = "Google Chrome 安装程式" .Size = New Size(466, 168) .Font = New Font("Tahoma", 8.25!) .FormBorderStyle = Windows.Forms.FormBorderStyle.Fixed3D .MaximizeBox = False .Controls.Add(tlpForm) End With With tlpForm .Location = New Point(-4, -1) .Size = Me.ClientSize .ColumnCount = 1 .ColumnStyles.Add(New ColumnStyle(SizeType.AutoSize, 0.0!)) .RowCount = 2 .RowStyles.Add(New RowStyle(SizeType.Percent, 40.0!)) .RowStyles.Add(New RowStyle(SizeType.Percent, 60.0!)) .Controls.Add(lblSetup, 0, 0) .Controls.Add(prgSetup, 0, 1) End With With lblSetup .AutoSize = True .Text = "正在安装 Google Chrome..." .Margin = New Padding(12) End With With prgSetup ' Marquee or Continuous .Style = ProgressBarStyle.Marquee .Size = New Size(0, 16) .MarqueeAnimationSpeed = 25 .Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top .Margin = New Padding(15, 8, 6, 0) End With With timerPrg .Interval = 25 .Enabled = True End With AddHandler timerPrg.Tick, AddressOf TimerPrg_Tick End Sub Private Sub TimerPrg_Tick() If prgSetup.Value = 100 Then prgSetup.Value = 0 prgSetup.Value += 1 End Sub End Class
x1 |
引用 | 编辑
sob790717
2014-01-11 20:08 |
2楼
▲ ▼ |
想再问问关于vb2010将设定档存放位置改成与执行档同一目录得如何做?
抱歉问题有点多,我是从VB6直升VB2010的,变化很大,几乎是从头再学一次VB x0 |
引用 | 编辑
ebolaman
2014-01-11 23:04 |
3楼
▲ ▼ |
下面是引用 sob790717 于 2014-01-11 20:08 发表的 : 只要知道执行档的资料夹为何,存在那就好 ㄧ般来说,如果只指定档案名称,都会存在和执行档同ㄧ目录 例 复制程式 IO.File.WriteAllText("123.txt", "test") 执行后应该会发现有个 123.txt 在 bin/Debug/ 资料夹下 至于手动指定资料夹, 有两种比较推荐的方式 复制程式 Application.StartupPath 复制程式 AppDomain.CurrentDomain.BaseDirectory 我当初也是先学 VB6, 过一阵子才选择跳进 .NET (VB 2010) 体系 要注意如果要学好 .NET,就必须放弃 VB6 的旧写法,虽然 .NET 还是可以用 VB6 的语法 但是有些旧语法在 .NET 上会跑较慢,或是不直观 想要把旧的语法完全去除, 可以将 专案属性 -> Reference -> Imported namespaces -> 将 Microsoft.VisualBasic 取消勾选 打程式码如果打旧的 VB6 语法,编辑器将不会提式 (例 MsgBox, Instr, Len),用了也无效 (VB.NET 对应的语法是 MessageBox, .IndexOf(), .Length()) 学 .NET 最方便的是,网路上 C# 的范例,可以毫不费力转成 VB.NET~ 仔细看语法的话会发现,每行几乎都对应同样的程式码 学好 VB.NET 最好的方式还是从基础开始,最好看书, 不要像我大都是网路上这点学学、那点学学 x0 |
引用 | 编辑
sob790717
2014-01-14 15:21 |
4楼
▲ ▼ |
忘了补充了
我的设定档是使用xml制的 就是 app.config 与 user.config 那种的 因为预设下他会把每一个版本的设定档分开放 所以等于是终端使用者每升级一次版本就要重新设定一次... 所以我才会询问上上楼的问题 x0 |
引用 | 编辑
ebolaman
2014-01-15 13:23 |
5楼
▲ |
下面是引用 sob790717 于 2014-01-14 15:21 发表的 : 如果使用者正在使用新的版本,可以呼叫以下方式来让旧版的设定 复盖到新版 复制程式 My.Settings.Upgrade() 至于该如何决定是否要升级(以上的方法),可以在 Settings 内加ㄧ个 scope 为 user 名称为 SettingsRequired 值 true 并用以下方法 复制程式 If My.Settings.UpgradeRequired Then My.Settings.Upgrade() My.Settings.UpgradeRequired = False My.Settings.Save() End If 如此ㄧ来,每次新版本,就只会让旧设定复写ㄧ次 其他的逻辑可以由你自行决定 另外有些人讨厌 user.config 在其他资料夹 想要弄在和执行档同一个资料夹, 也有另一个方法,叫做自订组态区段 (custom config sections) 可以呼叫 ConfigurationManager.OpenExeConfiguration() 决定从哪读取 user.config 缺点是和 My.Settings 比起来,程式码相对较多 其他方法就是 .ini, 自订 xml, .json, .yaml x0 |