引用 | 編輯
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 |