189 8069 5689

vb.netled8的简单介绍

VB.net的AxMSComm控件如何向LED屏发送数据

检查PC机与LED屏间串口通信线是否正确连接.

创新互联主要从事网站设计制作、做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务铜山,10年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

那你也得将通信协议叙述清楚。并将你的代码贴出。

vb.net 串口点亮小灯

SCON = 0x50; //REN=1允许串行接受状态,串口工作模式1 TMOD|= 0x20; 试下这个程序,PC发什么,它就回送什么,收到数据,点亮P2.0的LED。

使用VB.NET制作带歌词显示的mp3播放器

Public Class Form1

Dim soundname As String()

Dim i As Integer

Dim j, l As Boolean

Dim k As Integer

Dim filename As String '取歌曲的名字

Dim path As String()

Dim s, m As Integer

Dim luj As String

Dim count As Integer '用来声明选择歌曲的数目

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

selectsound()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim g As Graphics

g = Graphics.FromHwnd(Me.Handle)

Dim mfont As New Font("宋体", 20)

Dim mstringformat As New StringFormat

mstringformat.Alignment = StringAlignment.Center

mstringformat.LineAlignment = StringAlignment.Center

g.DrawString("X071616", mfont, Brushes.Black, 75, 328, mstringformat)

If ListBox1.Items.Count = 0 Then selectsound() : Exit Sub

playsound()

End Sub

Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll

Me.AxWindowsMediaPlayer1.settings.volume = TrackBar1.Value

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

If Timer1.Enabled = False Then

Timer1.Enabled = True

Else

Timer1.Enabled = False

End If

If i = 0 Then

Me.AxWindowsMediaPlayer1.Ctlcontrols.pause()

i = 1

Button3.Text = "继续"

Exit Sub

End If

If i = 1 Then

Me.AxWindowsMediaPlayer1.Ctlcontrols.play()

Button3.Text = "暂停"

i = 0

Exit Sub

End If

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

j = True

playsound()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Me.AxWindowsMediaPlayer1.Ctlcontrols.stop()

End Sub

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

Dim string1, ss, sss As String

string1 = ListBox1.SelectedItem.ToString.Substring(ListBox1.SelectedItem.ToString.LastIndexOf("\") + 1)

filename = string1.Substring(0, string1.LastIndexOf("."))

luj = ListBox1.SelectedItem.ToString.Substring(0, ListBox1.SelectedItem.ToString.LastIndexOf(".")) + ".lrc"

Me.HScrollBar1.Value = Me.AxWindowsMediaPlayer1.Ctlcontrols.currentPosition / (Me.AxWindowsMediaPlayer1.currentMedia.duration + 0.001) * 1000

ss = Me.AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString

Me.Label1.Text = ss

If Dir(luj) Nothing Then

Dim fr As System.IO.StreamReader = New System.IO.StreamReader(luj, System.Text.Encoding.Default)

sss = fr.ReadLine '我们读取的第一行歌词

While (sss "")

If (sss.LastIndexOf(ss) -1) Then '时间匹配了歌词中的时间

Me.TextBox1.Text = sss.Substring(sss.LastIndexOf("]") + 1)

Form2.TextBox1.Text = Me.TextBox1.Text

End If

sss = fr.ReadLine

End While

Else

TextBox1.Text = "Not Find! 请从网上下载歌词!"

Form2.TextBox1.Text = "Not Find! 请从网上下载歌词!"

End If

Label1.Text = "当前进度:" + Me.AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString

End Sub

Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll

Me.AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = Me.HScrollBar1.Value / 1000 * Me.AxWindowsMediaPlayer1.currentMedia.duration

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

Me.AxWindowsMediaPlayer1.Ctlcontrols.fastForward()

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

Me.AxWindowsMediaPlayer1.Ctlcontrols.fastReverse()

End Sub

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

i = 0

j = False

l = False

Label2.Text = "歌曲名: "

Label3.Text = "歌曲演唱者: "

Label4.Text = "歌曲描述: "

Label5.Text = "歌曲类型: "

Label6.Text = "歌曲大小: "

Button8.Enabled = False

End Sub

Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick

Me.AxWindowsMediaPlayer1.URL = ListBox1.Items(ListBox1.SelectedIndex)

Me.AxWindowsMediaPlayer1.Ctlcontrols.play()

Label2.Text = "歌曲名: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Title")

Label3.Text = "歌曲演唱者: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Author")

Label4.Text = "歌曲描述: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Description")

Label5.Text = "歌曲类型: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileType")

Label6.Text = "歌曲大小: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileSize")

Timer1.Start()

End Sub

Private Sub playsound()

Timer1.Stop()

TrackBar1.Value = Me.AxWindowsMediaPlayer1.settings.volume

If j = False Then

Me.AxWindowsMediaPlayer1.URL = ListBox1.Items(ListBox1.SelectedIndex)

ElseIf j = True Then

k = (ListBox1.SelectedIndex + 1) Mod soundname.Length

Me.AxWindowsMediaPlayer1.URL = ListBox1.Items(k)

j = False

End If

ListBox1.SelectedIndex = k

Me.AxWindowsMediaPlayer1.Ctlcontrols.play()

Label2.Text = "歌曲名: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Title")

Label3.Text = "歌曲演唱者: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Author")

Label4.Text = "歌曲描述: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Description")

Label5.Text = "歌曲类型: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileType")

Label6.Text = "歌曲大小: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileSize")

Timer1.Start()

End Sub

Private Sub selectsound()

Dim open As New OpenFileDialog

Dim i As Integer

With open

.Filter = "所有mp3文件(*.mp3)|*.mp3|所有wma文件(*.wma)|*.wma"

.Multiselect = True

.Title = "请选择歌曲"

End With

If (open.ShowDialog = Windows.Forms.DialogResult.OK) Then

soundname = open.FileNames

For i = 0 To soundname.GetUpperBound(0)

ListBox1.Items.Add(soundname(i))

Next

ListBox1.SelectedIndex = 0

End If

End Sub

Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As System.Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange

If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsMediaEnded Then

j = True

Timer2.Start()

End If

End Sub

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

playsound()

Timer2.Stop()

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Timer1.Stop()

If ListBox1.SelectedIndex = 0 Then

Me.AxWindowsMediaPlayer1.URL = ListBox1.Items(soundname.Length - 1)

ListBox1.SelectedIndex = (soundname.Length - 1)

Else

Me.AxWindowsMediaPlayer1.URL = ListBox1.Items((ListBox1.SelectedIndex Mod soundname.Length) - 1)

ListBox1.SelectedIndex = (ListBox1.SelectedIndex Mod soundname.Length) - 1

End If

Me.AxWindowsMediaPlayer1.Ctlcontrols.play()

Label2.Text = "歌曲名: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Title")

Label3.Text = "歌曲演唱者: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Author")

Label4.Text = "歌曲描述: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("Description")

Label5.Text = "歌曲类型: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileType")

Label6.Text = "歌曲大小: " + Me.AxWindowsMediaPlayer1.currentMedia.getItemInfo("FileSize")

Timer1.Start()

End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

Form2.Show()

End Sub

End Class


分享标题:vb.netled8的简单介绍
网页URL:http://cdxtjz.cn/article/dojcodc.html

其他资讯