新聞中心
本文向大家介紹VB Update方法,可能好多人還不了解VB Update方法,沒有關(guān)系,看完本文你肯定有不少收獲,希望本文能教會你更多東西。在VB Update方法被調(diào)用前,在ConsoleProgressBar對象中什么也沒有發(fā)生:

創(chuàng)新互聯(lián)公司主營扎賚諾爾網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都App制作,扎賚諾爾h5微信小程序定制開發(fā)搭建,扎賚諾爾網(wǎng)站營銷推廣歡迎扎賚諾爾等地區(qū)企業(yè)咨詢
- Public Sub Update(ByVal CurrentValue As Long)
- m_currentValue = CurrentValue
- m_currentBarLength = CInt((m_currentValue / m_maximumValue) * m_length)
- Refresh()
- End Sub
這個VB Update方法使用一個值作參數(shù)(在此是指當(dāng)前剛剛復(fù)制的文件數(shù))。我設(shè)置成員m_currentValue,然后計算m_currentBarLength。計算的結(jié)果為進(jìn)度條當(dāng)前應(yīng)該覆蓋的列數(shù)。
最后,我調(diào)用Refresh方法,它又調(diào)用UpdatePercentComplete、UpdateProgressBar和UpdateMessageBar方法。
因為所有這三個方法功能相類似,所以我將集中討論UpdateProgressBar方法:
- Private Sub UpdateProgressBar()
- Dim originalForegroundColor As ConsoleConsoleColor = Console.ForegroundColor
- Dim originalBackgroundColor As ConsoleConsoleColor = Console .BackgroundColor
- Console.ForegroundColor = ConsoleColor.Black
- Console.BackgroundColor = ConsoleColor.Green
- Console.SetCursorPosition(m_left + 1 m_progressBarRow)
- Dim progress As New String("O", m_currentBarLength)
- Console.Write(progress)
- Console.ForegroundColor =originalForegroundColor
- Console.BackgroundColor = originalBackgroundColor
- End Sub
首先,該代碼保存當(dāng)前的前景和背景顏色。然后,它把ForegroundColor屬性設(shè)置為黑色,把BackgroundColor屬性設(shè)置為綠色。在把光標(biāo)放置到進(jìn)度條的左邊緣后,它打印一串長度為m_currentBarLength的“O”。
其它問題
這個DirCopy應(yīng)用程序,雖然有些用處,但是還遠(yuǎn)非成品。為了使其更為強(qiáng)壯,還需要增加大量的錯誤處理方式。你還可以改進(jìn)ConsoleProgressBar類以實現(xiàn)更靈活的控制。下列是一些可能的改進(jìn):
◆允許控制進(jìn)度條的位置和長度
◆允許百分比完成區(qū)域放到你選擇的任何位置
◆允許定制進(jìn)度條中的消息
◆添加一個選項以選擇水平的或垂直的進(jìn)度條
【編輯推薦】
- VB 2005中開發(fā)新一代控制臺應(yīng)用程序
- 簡單講解VB開發(fā)分布式
- 淺析VB Script開發(fā)自動化測試
- 淺談VB開發(fā)系統(tǒng)知識
- VB.NET應(yīng)用程序中多線程的應(yīng)用實例
本文標(biāo)題:詳細(xì)分析VB Update方法
文章URL:http://fisionsoft.com.cn/article/djsihco.html


咨詢
建站咨詢
