vb.netln的簡單介紹

vb.net中的int

Dim n As Integer = Integer.Parse(Command.ExecuteScalar("select count(sno) from student").ToString())

成都創(chuàng)新互聯(lián)專注于天臺網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供天臺營銷型網(wǎng)站建設(shè),天臺網(wǎng)站制作、天臺網(wǎng)頁設(shè)計、天臺網(wǎng)站官網(wǎng)定制、小程序開發(fā)服務(wù),打造天臺網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供天臺網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。

ExecuteScalar 返回的是 object 類型

關(guān)于播放器中的功能(歌詞同步),急求VB.NET代碼??!

思路很簡單可以定義一個結(jié)構(gòu)LyricStructure Lyric

Dim Time As Single

Dim Content As String

End Structure聲明一個列表 Private Lyrics As New List(Of Lyric)然后以文本方式把歌詞文件讀入一個變量 并對它進行分析 分別把時間和歌詞內(nèi)容存入一個Lyric,并加入Lyrics中。代碼如下:(假設(shè)歌曲文件的路徑為path)Dim LrcPath As String== IO.Path.GetDirectoryName(cPath) "/" IO.Path.GetFileNameWithoutExtension(cPath) ".lrc"If IO.File.Exists(LrcPath= True Then AnalysisLyric() Private Sub AnalysisLyric()

Lyrics.Clear() '先清空列表

Dim tm As Byte

Dim sr As New IO.StreamReader(LrcPath, System.Text.Encoding.Default) '讀取歌詞文件

Do While sr.EndOfStream = False '判斷是否處于文件流末尾

Dim tmpStr As String = sr.ReadLine '讀取一行

If tmpStr.Length 5 Then Continue Do '長度小于5則跳過,進行下一次循環(huán)

Select Case Mid(tmpStr, 2, 2) '判斷第2-3個字符 因為歌詞里的注釋都是[ti:***]類似的結(jié)構(gòu)

Case "ti"

lTitle = Mid(tmpStr, 5, tmpStr.Length - 5)

Case "ar"

lArtist = Mid(tmpStr, 5, tmpStr.Length - 5)

Case "al"

lAlbum = Mid(tmpStr, 5, tmpStr.Length - 5)

Case "by"

lAuthor = Mid(tmpStr, 5, tmpStr.Length - 5)

Case Else '如果不為以上的內(nèi)容 則為歌詞正文,進行以下操作

If Not Mid(tmpStr, 1, 6) Like "?##:##" Then Continue Do

Dim time(-1) As String '因為有時歌詞是以[00:00.00][00:00.00]**** 這樣歌詞把多個時間存放在一起的 ,所以定義一個數(shù)組來存放歌詞

Do '因為不確定時間的個數(shù),所以此處必須循環(huán)判斷

tm = InStr(tmpStr, "]") '因為歌詞時間有時是[00:00.00]形式,有時是[00:00]形式,所以不能單純的截取第幾個字符 ,我是根據(jù)查找']'字符來進行判斷的

ReDim Preserve time(time.GetUpperBound(0) + 1) 為time數(shù)組重新分配大小

time(time.GetUpperBound(0)) = Mid(tmpStr, 1, tm) 'time.GetUpperBound(0)返回數(shù)組的第一維的最大下標

tmpStr = IIf(tmpStr.Length = tm, " ", Mid(tmpStr, tm + 1)) '歌詞內(nèi)容

Loop While Mid(tmpStr, 1, 6) Like "?##:##" '如果截取剩下的部分依然匹配的話繼續(xù)循環(huán)

For Each t In time '為每個時間都創(chuàng)建一個Lyric變量

Dim ln As Lyric

ln.Time = SwitchTime(Mid(t, 2, t.Length - 2))

ln.Content = tmpStr

Lyrics.Add(ln)

Next

End Select

Loop

sr.Close() 關(guān)閉流

Sort() '把所有Lyric按時間順序排序

End Sub Private Function SwitchTime(ByVal time As String) As Single ‘這個函數(shù)是用來把00:00.00格式的時間轉(zhuǎn)化成以秒數(shù)顯示的數(shù)值

Dim tm As Single

Dim minute As Single = Val(Mid(time, 1, 2))

Dim second As Single = Val(Mid(time, 4, 5))

tm = minute * 60 + second

Return tm

End Function Private Sub Sort()

For i = 0 To Lyrics.Count - 2

For j = i To Lyrics.Count - 1

If Lyrics(i).Time Lyrics(j).Time Then

Dim tm As Lyric = Lyrics(i)

Lyrics(i) = Lyrics(j)

Lyrics(j) = tm

End If

Next

Next

End Sub 接下來是顯示歌詞的問題了 ,只要有每句歌詞和對應(yīng)的時間,那么問題就好辦了。你可以用Windows Media Player控件返回的時間和每句歌詞的時間做比較,來判斷應(yīng)該顯示那一句。代碼是很久前寫的 ,那時沒加注釋,都是剛剛加上去的喲,你可以根據(jù)你的實際情況自己修改,有什么不懂的地方可以繼續(xù)問我哈~~

vb.net是什么

VB.net是微軟最新平臺技術(shù),是.netframeworkSDK的一種語言。VB.net和VC#.net在功能上沒有區(qū)別。編譯以后生成的可執(zhí)行文件被稱為Assembly,即

程序集

文章標題:vb.netln的簡單介紹
轉(zhuǎn)載注明:http://muchs.cn/article32/dosjhpc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站、網(wǎng)站設(shè)計、App設(shè)計、面包屑導(dǎo)航網(wǎng)站維護、網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化