vb.net工作提醒 vbnet trim

VB.NET问题 , 做一个定时响铃提醒程序,怎样在程序中引用铃音 , 请写写代码,是在timer中添加代码吗把类似下面的三行代码放入timer即可 。关键是放音程序 。
DealWav.mciSendString "open "sA"alias wav", sB, Len(sB), 0
DealWav.mciSendString "play wav", sB, Len(sB), 0
DealWav.mciSendString "closewav ", sB, Len(sB), 0
送你DealWav模块
Dim WAVBuffer()As Byte
Dim DataLenOutAs Long
Dim Datapos1As Long
Dim Datapos2As Long
Dim ChunkLenAs Long
Dim factposAs Long
Type PCMWAVEFORMAT'标准PCM格式定义
wFormatTagAs Integer'格式标志 , 区分不同的格式,PCM为1
nChannelsAs Integer'音频通道数,单声道为1 , 立体声为2
nSamplesPerSecAs Long'每秒的采样数,即采样率 。
'标准的采样率有8.000kHz、11.025kHz、
'22.050kHz、44.100kHz等 。
nAvgBytesPerSecAs Long'每秒的字节数,即数据率 。
'数据率=通道数×采样率×采样大小/8
nBlockAlignAs Integer'块对齐,即波形数据的最小单位 。
'块对齐=通道数×采样大小/8
wBitsPerSampleAs Integer'每个采样所占的位数,即采样大小 。
'采样大小有8位和16位两种 。
End Type
Private Type WaveHead
strRiffAs String * 4'00H4char"RIFF"标志
lngFileLenAs Long'04H4longint文件长度
strWaveAs String * 4'08H4char"WAVE"标志
strFmtAs String * 4'0CH4char"fmt"标志
lngTmpAs Long'10H4过渡字节(不定)
intFormatAs Integer'14H2int格式类别(10H为PCM形式的声音数据)
intChanAs Integer'16H2int通道数,单声道为1 , 双声道为2
intFreqAs Long'18H2int采样率(每秒样本数),表示每个通道的播放速度,
lngSendSpeedAs Long'1CH4longint波形音频数据传送速率,其值为通道数×每秒数据位数×每样本的数据位数/8 。播放软件利用此值可以估计缓冲区的大小 。
intBlockAs Integer'20H2int数据块的调整数(按字节算的),其值为通道数×每样本的数据位值/8 。播放软件需要一次处理多个该值大小的字节数据,以便将其值用于缓冲区的调整 。
intBitAs Integer'22H2每样本的数据位数 , 表示每个声道中各个样本的数据位数 。如果有多个声道,对每个声道而言,样本大小都一样 。
strDataAs String * 4'24H4char数据标记符"data"
lngDataLenthAs Long'28H4longint语音数据的长度
End Type
Public Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
' flag uitzetten
Public Const SND_SYNC = H0
Public Const SND_ASYNC = H1
Public Const SND_NODEFAULT = H2
Public Const SND_MEMORY = H4
Public Const SND_LOOP = H8
Public Const SND_NOSTOP = H10
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
'Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Public Declare Sub RtlMoveMemory Lib "kernel32" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Private Sub Command1_Click()
'为了防止随意选取的两个wav文件格式不同 , 我干脆就将同一个文件重复两次
LinkWav "C:\WINNT\Media\ringout.wav", "C:\WINNT\Media\ringout.wav", "f:\temp.wav"
End Sub
Private Function getWavHead(strFileName As String) As WaveHead
'获取文件头
Dim iFreeFile
iFreeFile = FreeFile()
On Error GoTo ErrHandle
Dim MyHeadAs WaveHead
Open strFileName For Binary As #iFreeFile
Get #iFreeFile, , MyHead
Close #iFreeFile
getWavHead = MyHead
ErrHandle:
End Function
Public Function LinkWav(strFileName1 As String, strFileName2 As String, strOutFile As String) As Boolean
Dim headFirstAs WaveHead
Dim headNextAs WaveHead
Dim headNewAs WaveHead'新文件的头
Dim Data1()As Byte
Dim Data2()As Byte
Dim iAs Long
LinkWav = False
'获取头
headFirst = getWavHead(strFileName1)
headNext = getWavHead(strFileName2)
'文件头比较
DoEvents'这里应该对两个头作比较,如果采样率,声道数等等不一致的话不能进行连接
'偶就偷懒不做这个校验啦,如果要实际应用千万要完成这一块的代码
'创建新头
headNew = headFirst'先拷贝一个头过来
headNew.lngFileLen = headFirst.lngDataLenthheadNext.lngDataLenth37
'文件长度等于两个文件的数据长度相加再加上头的长度,为什么是37呢?我也不明白!头的总长度是44,去掉4个字节的riff标志和4个字节的文件长度也应该是36哇 。可是你打开一个wav文件把文件长度字段减去数据长度字段 , 就是活见鬼的37 。我想了好久总想不通最后妥协直接写了个37在这里!:(
headNew.lngDataLenth = headFirst.lngDataLenthheadNext.lngDataLenth
'数据段的长度就是两个文件的数据相加啦
'下面是文件操作,为了加快编码速度减少脑细胞损伤,下面的代码效率很低,大家自己优化啦,如果直接用下面的代码劝大家不要读太大的文件,很够呛哦~~
'把两个文件的数据读出来?。?
ReDim Data1(headFirst.lngDataLenth - 1)
'Open strFileName1 For Random As #1 Len = 1
Open strFileName1 For Binary As #1
For i = 0 To headFirst.lngDataLenth - 1
Get #1, 45i, Data1(i)
Next
Close #1
ReDim Data2(headNext.lngDataLenth - 1)
'Open strFileName2 For Random As #1 Len = 1
Open strFileName2 For Binary As #1 'Len = 1
For i = 0 To headNext.lngDataLenth - 1
Get #1, 45i, Data2(i)
Next
Close #1
'开始写数据啦
'Open strOutFile For Random As #1 Len = 1
Open strOutFile For Binary As #1
Put #1, , headNew'将头写入文件中 。
'Close #1
'Open strOutFile For Random As #1 Len = 1
For i = 0 To UBound(Data1)
Put #1, 45i, Data1(i)'将第一个记录写入文件中 。
Next
For i = 0 To UBound(Data2)
Put #1, , Data2(i)'将第一个记录写入文件中 。
Next
Close #1'关闭文件 。
End Function
'合并两个WAV声音文件
Public Function WavMerge(Wave1() As Byte, Wave2() As Byte) As Variant
Dim xxAs Long
Dim Y$
'1,确定datachunk的起始点(不同的WAV文件可能会不尽相同)
Do While Y$"data"
Y$ = Chr(Wave1(xx))Chr(Wave1(xx1))Chr(Wave1(xx2))Chr(Wave1(xx3))
xx = xx1
If xx1000 Then
MsgBox "未知格式"
Exit Function
End If
Loop
Datapos1 = (xx - 1)8
xx = 0
Y$ = ""
Do While Y$"data"
Y$ = Chr(Wave2(xx))Chr(Wave2(xx1))Chr(Wave2(xx2))Chr(Wave2(xx3))
xx = xx1
If xx1000 Then
MsgBox "未知格式"
Exit Function
End If
Loop
Datapos2 = (xx - 1)8
xx = 0
Y$ = ""
'2,确定第一个参数Wave1声音中是否包含可选的factchunk
factpos = 0
Do While Y$"fact"
Y$ = Chr(Wave1(xx))Chr(Wave1(xx1))Chr(Wave1(xx2))Chr(Wave1(xx3))
xx = xx1
If xx1000 Then
xx = 0
Exit Do
End If
Loop
factpos = xx - 1
If factpos = -1 Then factpos = 36
DataLenOut = UBound(Wave1)1 - Datapos1UBound(Wave2)1 - Datapos2
ReDim WAVBuffer(factpos19DataLenOut)
'3,写入合并后的RIFF('wave'...fmt...[fact]...头信息
RtlMoveMemory WAVBuffer(0), Wave1(0), factpos'注:采样速率,平均数据速率,采样大小,声道以Wave1参数为准
WAVBuffer(factpos) = Asc("f"):WAVBuffer(factpos1) = Asc("a")
WAVBuffer(factpos2) = Asc("c"):WAVBuffer(factpos3) = Asc("t")
ChunkLen = 4
RtlMoveMemory WAVBuffer(factpos4), ChunkLen, 4
RtlMoveMemory WAVBuffer(factpos8), DataLenOut, 4
WAVBuffer(factpos12) = Asc("d"):WAVBuffer(factpos13) = Asc("a")
WAVBuffer(factpos14) = Asc("t"):WAVBuffer(factpos15) = Asc("a")
RtlMoveMemory WAVBuffer(factpos16), DataLenOut, 4
'4,写入合并后的datachunk(即所有的samples,先Wave1,后Wave2)
RtlMoveMemory WAVBuffer(factpos20), Wave1(Datapos1), UBound(Wave1) - Datapos11
RtlMoveMemory WAVBuffer(factpos20UBound(Wave1) - Datapos11), Wave2(Datapos2), UBound(Wave2) - Datapos21
'5,更正RIFF头信息
ChunkLen = UBound(WAVBuffer) - 7
RtlMoveMemory WAVBuffer(4), ChunkLen, 4
'6,结束
WavMerge = WAVBuffer
End Function
'合并多个文件
Public Function f_LinkWav(cFile As Collection, sOutFile As String) As Boolean
Dim headFirstAs WaveHead
Dim headNextAs WaveHead
Dim headNewAs WaveHead'新文件的头
Dim byteData()As Byte
Dim iFreeFile As Integer
Dim iAs Long
Dim j As Long
Dim iA
Dim lData As Long
f_LinkWav = False
iFreeFile = FreeFile()
'获取头
headFirst = getWavHead(cFile(1))
lData = https://www.04ip.com/post/headFirst.lngDataLenth - 1
ReDim Preserve byteData(lData)
'Open strFileName1 For Random As #1 Len = 1
Open cFile(1) For Binary As #iFreeFile
For i = 0 To lData
Get #iFreeFile, 45i, byteData(i)
Next
Close #iFreeFile
headNew = headFirst
headNew.lngFileLen = headFirst.lngDataLenth
headNew.lngDataLenth = headFirst.lngDataLenth
For iA = 2 To cFile.Count
headNext = getWavHead(cFile(iA))
headNew.lngFileLen = headNew.lngFileLenheadNext.lngDataLenth37
headNew.lngDataLenth = headNew.lngDataLenthheadNext.lngDataLenth
ReDim Preserve byteData(lDataheadNext.lngDataLenth)
Open cFile(iA) For Binary As #iFreeFile 'Len = 1
For i = 1 To headNext.lngDataLenth
Get #iFreeFile, 44i, byteData(lDatai)
Next
Close #iFreeFile
lData = https://www.04ip.com/post/lDataheadNext.lngDataLenth
Next
'开始写数据啦
'Open strOutFile For Random As #1 Len = 1
If Dir(sOutFile, vbNormal)"" Then Kill sOutFile
Open sOutFile For Random As #iFreeFile
Put #iFreeFile, , headNew'将头写入文件中 。
Close #iFreeFile
j = UBound(byteData)1
'For iA = 2 To giCalltimes
'ReDim Preserve byteData(UBound(byteData)j)
'For i = 0 To j - 1
'byteData(ji) = byteData(i)'将第一个记录写入文件中 。
'Next
'Next iA
Open sOutFile For Random As #iFreeFile Len = 1
For i = 0 To UBound(byteData)
Put #iFreeFile, 45i, byteData(i)'将第一个记录写入文件中 。
Next
' j = UBound(byteData)
'For iA = 2 To giCalltimes
'For i = 0 To UBound(byteData)
'Put #iFreeFile, 45ij1, byteData(i)'将第一个记录写入文件中 。
'Next
'j = jUBound(byteData)
'Next
Close #iFreeFile'关闭文件 。
f_LinkWav = True
End Function
Public Function f_MciChkEnd()
Dim MCIStatus As String * 255
Dim lA
f_MciChkEnd = False
lA = mciSendString("status wav mode", MCIStatus, Len(MCIStatus), 0)
If UCase(Left$(MCIStatus, 7)) = "STOPPED" Or Left$(MCIStatus, 2) = "结束" Then f_MciChkEnd = True
End Function
Public Function SendComReturnString(com As String) As String
Dim FeedBackAs Long, ReturnStringAs String * 255
ReturnString = String(255, Chr(0))
FeedBack = mciSendString(com, ReturnString, 255, 0)
If FeedBack Then
Dim sAs String * 255
'mciGetErrorString FeedBack, s, 255
SendComReturnString = vbNullString
Else
SendComReturnString = Left(ReturnString, InStr(1, ReturnString, Chr(0)) - 1)
End If
End Function
vb.net 中生成exe文件,运行时出现错误提醒,求解决办法 。Items collection cannot be modified when the DataSource property is set.
请修改数据集中数据源vb.net工作提醒的设置.
vb.net怎么给button加tip提示1:从工具箱里拖一个ToolTip控件到窗体上,成为ToolTip1
2:选择你要添加提示的Button1,此时Button1的属性中,最下面就多了1个ToolTip1上的ToolTip属性了,就在那里编辑文字
3:ToolTip1可以编辑tip提示的各个关键属性,一个ToolTip1能满足控制多个控件的tip
祝进步!
怎样在vb.net里做一个日历提醒?急~~~~~~Public Class Form1
Dim 设置时间 As DateTime
Private Sub D1_CloseUp(ByVal sender As Object, ByVal e As System.EventArgs) Handles 日期时间选择.CloseUp
和.Text = 日期时间选择.Value
设置时间 = 日期时间选择.Value
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
日期时间选择.Value = https://www.04ip.com/post/Now
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Now.ToString = 和.Text Then
提醒显示.Text = "时间到了 你该去做些什么事了吧"
'Timer1.Enabled = False
Else
提醒显示.Text = "现在时间是:"Now
End If
End Sub
Private Sub 和_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 和.TextChanged
设置时间 = 和.Text
End Sub
End Class
vb.net 鼠标停留在label,textbox上时,如何显示提示信息Label 控件用于显示用户不能编辑vb.net工作提醒的文本或图像 。含义vb.net工作提醒:用于显示标签
TextBox 控件通常用于可编辑文本vb.net工作提醒,不过也可使其成为只读控件vb.net工作提醒,文本框用于获取用户输入或显示文本 。
这就是区别vb.net工作提醒,Label只能显示,而TextBox可以修改,输入数据
想在vb.net的程序中有一个语音提示 , 该怎么写首先添加一个系统的语音COM组件的引用microsoft speech object library然后在程序中声明一个语音类dim RC As SpeechLib.SpSharedRecoContext这个类有一些事件,如果你要处理它的一些事件,可以用withevent来声明然后在窗体LOAD事件或你需要的地方先创建一个实例RC = New SpeechLib.SpSharedRecoContext当一个RC被实例化后,系统就会运行语音识别程序.前提是你的系统已经正确安装这个功能.一般默认就已经安装好的.其次提醒一下,WIN7的语音识别比XP的好N倍.从阅读到侦听都好很多.然后就可以在你需要阅读的地方使用RC.Voice.Speak("hello 我", 11)11那里是一些枚举,用来标识系统用前台还是后台或其他方式来阅读文字,简单的来说就是阅读的时候不会卡住你的程序.你可以选其他的枚举来试试作用.以上为阅读部分.如果需要程序听你说话,则需要声明一个侦听类dim RG As SpeechLib.ISpeechRecoGrammar在初始化时将之与上面的RC建立关系,此时则必须要用withevent来声明上面的RC,因为涉及电脑听到你的语音后,会触发一个事件,并将听到的内容传递到该事件.其次,要让系统听到的解析为命令,就必须准备一个XML结构的文件来保存那些固定的命令.如果电脑在XML文件中找不到那些固定命令或同时不属于系统命令,电脑将会将其解释为听写.RG = RC.CreateGrammar '(0)
RG.CmdLoadFromFile("听到.xml", SpeechLib.SpeechLoadOption.SLODynamic)
RG.CmdSetRuleIdState(0, SpeechLib.SpeechRuleState.SGDSActive)然后写一个过程来处理听到的事件Private Sub 听到命令(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal 话语 As SpeechLib.ISpeechRecoResult) Handles RC.Recognition RC.Voice.Speak("我听到了"话语.PhraseInfo.GetText, 11)End Sub以上为侦听部分.下面列一个XML的例文?xml version="1.0" encoding="gb2312"?
GRAMMAR LANGID="804"
RULE NAME="命令" TOPLEVEL="ACTIVE"
L
P打开播放器
P上我的QQ
P关闭你自己 /L
/RULE
/GRAMMAR要让系统正确地侦听到你说的话,前提你必须运行语音识别程序并让其激活到"正在聆听"状态.并且你必须有一个能正常使用的话筒而且保证话筒已经打开.(废话-_-|||)以上就是用VB.NET语音识别的最基本的一些操作.希望对你有帮助.更深入的内容有兴趣的话可以和我一起研究.
【vb.net工作提醒 vbnet trim】vb.net工作提醒的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbnet trim、vb.net工作提醒的信息别忘了在本站进行查找喔 。

    推荐阅读