|
Thanks, i will try using this
|
|
|
|
|
OK this one has me baffled I just got done writing this program, and I only had a few typos corrected them. The program now starts up and run just fine, but it does not play the wav sounds. I have a textbox and two buttons, btnbrowse and btnplay I'm supposed to be able to browse through my hard drive, find a wav sound and then play it, could someone help me with this please. Thank you
----------------------------------------------------------------------------
Option Strict Off
Option Explicit On
Module modauto
Sub LoadFile(ByRef inFile As String)
Dim hmem As Integer
Dim mmckinfoparentIn As MMCKINFO
Dim mmckinfosubchunkIn As MMCKINFO
Dim hmmioIn As Integer
Dim mmioinf As mmioinfo
mmioinf.adwInfo = Space(4)
hmmioIn = mmioOpen(inFile, mmioinf, MMIO_READ)
If hmmioIn = 0 Then Exit Sub
mmioDescendparent(hmmioIn, mmckinfoparentIn, 0, MMIO_FINDRIFF)
mmckinfosubchunkIn.CKID = mmioStringToFOURCC("fmt", 0)
mmioDescend(hmmioIn, mmckinfosubchunkIn, mmckinfoparentIn, MMIO_FINDCHUNK)
mmioReadFormat(hmmioIn, format_wave, Len(format_wave))
mmioAscend(hmmioIn, mmckinfosubchunkIn, 0)
mmckinfosubchunkIn.CKID = mmioStringToFOURCC("data", 0)
mmioDescend(hmmioIn, mmckinfosubchunkIn, mmckinfoparentIn, MMIO_FINDCHUNK)
GlobalLock(hmem)
hmem = GlobalAlloc(&H40S, mmckinfosubchunkIn.cksize)
bufferin = GlobalFree(hmem)
mmioRead(hmmioIn, bufferin, mmckinfosubchunkIn.cksize)
numSamples = mmckinfosubchunkIn.cksize / format_wave.nBlockAlign
mmioClose(hmmioIn, 0)
End Sub
Sub play(ByVal soundcard As Short)
Dim rc As Integer
Dim lFlags As Integer
lFlags = Callback_Function
If soundcard <> -1 Then lFlags = lFlags Or WAVE_MAPPED
rc = waveOutOpen(hwaveout, soundcard, format_wave, 0, 0, lFlags)
If (rc <> 0) Then Exit Sub
outhdr.lpData = bufferin
outhdr.dwBufferLenght = numsamples * format_wave.nBlockAlign
outhdr.dwFlags = 0
outhdr.dwLoops = 0
waveOutPrepareHeader(hwaveout, outhdr, Len(outhdr))
waveOutWrite(hwaveout, outhdr, Len(outhdr))
End Sub
Public whdr As WAVEHDR
Public format_wave As WAVEFORMAT
Public outhdr As WAVEHDR
Public bufferin As Integer
Public numsamples As Integer
Public hwaveout As Integer
Public Const MMIO_Read As Short = &H0S
Public Const Callback_Function As Integer = &H30000
Public Const WAVE_MAPPED As Short = &H4S
Public Const MMIO_FINDCHUNK As Short = &H10S
Public Const MMIO_FINDRIFF As Short = &H20S
Structure MMCKINFO
Dim CKID As Integer
Dim cksize As Integer
Dim fcctype As Integer
Dim dwdataoffset As Integer
Dim dwflags As Integer
End Structure
Structure mmioinfo
Dim dwflags As Integer
Dim fccIOproc As Integer
Dim pIOProc As Integer
Dim wErrorRet As Integer
Dim htask As Integer
Dim cchBuffer As Integer
Dim pchBuffer As String
Dim pchnext As String
Dim pchEndRead As String
Dim pchEndWrite As String
Dim lBufOffset As Integer
Dim lDiskOffset As Integer
Dim adwInfo As String
Dim dwReserved1 As Integer
Dim dwReserved2 As Integer
Dim hmmio As Integer
End Structure
Structure WAVEFORMAT
Dim wFormattag As Short
Dim nChannels As Short
Dim nSamplespersec As Integer
Dim nAvgBytespersec As Integer
Dim nBlockAlign As Short
Dim wBitsPerSample As Short
Dim cbSize As Short
End Structure
Structure WAVEHDR
Dim lpData As Integer
Dim dwBufferLenght As Integer
Dim dwBytesRecorded As Integer
Dim dwUser As Integer
Dim dwFlags As Integer
Dim dwLoops As Integer
Dim lpNext As Integer
Dim Reserved As Integer
End Structure
Declare Function waveOutWrite Lib "winmm.dll" (ByVal hWaveout As Integer, ByRef lpWaveoutHdr As WAVEHDR, ByVal uSize As Integer) As Integer
Declare Function waveOutPrepareHeader Lib "winmm.dll" (ByVal hWavein As Integer, ByRef lpWaveInHdr As WAVEHDR, ByVal uSize As Integer) As Integer
Declare Function mmioRead Lib "winmm.dll" (ByVal hmmio As Integer, ByVal pch As Integer, ByVal cch As Integer) As Integer
Declare Function waveOutOpen Lib "winmm.dll" (ByRef lphWaveIn As Integer, ByVal uDeviceID As Integer, ByRef lpFormat As WAVEFORMAT, ByVal dwCALLBACK As Integer, ByVal dwInstance As Integer, ByVal dwFlags As Integer) As Integer
Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Integer, ByVal dwBytes As Integer) As Integer
Declare Function GlobalLock Lib "kernel32" (ByVal hmem As Integer) As Integer
Declare Function mmioAscend Lib "winmm.dll" (ByVal hmmio As Integer, ByRef lpck As MMCKINFO, ByVal uFlags As Integer) As Integer
Declare Function GlobalFree Lib "kernel32" (ByVal hmem As Integer) As Integer
Declare Function mmioOpen Lib "winmm.dll" Alias "mmioOpenA" (ByVal szFileName As String, ByRef lpmmioinfo As mmioinfo, ByVal dwOpenFlags As Integer) As Integer
Declare Function mmioDescendparent Lib "winmm.dll" Alias "mmioDescend" (ByVal hmmio As Integer, ByRef lpck As MMCKINFO, ByVal x As Integer, ByVal uFlags As Integer) As Integer
Declare Function mmioReadFormat Lib "winmm.dll" Alias "mmioRead" (ByVal hmmio As Integer, ByRef pch As WAVEFORMAT, ByVal cch As Integer) As Integer
Declare Function mmioClose Lib "winmm.dll" (ByVal hmmio As Integer, ByVal uFlags As Integer) As Integer
Declare Function mmioStringToFOURCC Lib "winmm.dll" Alias "mmioStringToFOURCCA" (ByVal sz As String, ByVal uFlags As Integer) As Integer
Declare Function mmioDescend Lib "winmm.dll" (ByVal hmmio As Integer, ByRef lpck As MMCKINFO, ByRef lpckparent As MMCKINFO, ByVal uFlags As Integer) As Integer
End Module
|
|
|
|
|
You've got WAY too much code for this. How about getting some pointers from How To Play a Waveform (.WAV) Sound File in Visual Basic[^] on MSDN. It's written for VB4, VB5, and VB6, but is easily convertable to VB.NET code.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, I have the following two procedure:
Private Sub btnEvalGuide_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnEvalGuide.Click
' the code work here.
' ...
End Sub
Private Sub btnUseDtGl_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnIntVuDmExp.Click
' the code work here.
' ...
' ...
' need to call btnEvalGuide.Click
' but i don't know how to do it.
End Sub
When the code in btnIntVuDmExp.Click run it do it task and finally i need it to call to btnEvalGuide.Click . But i don't know how to do it. Can anyone give me a suggestion???
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
it seems that btnEvalGuide and btnIntVuDmExp both are buttons .u can can use
call btnEvalGuide_Click(sender,e)
that's all.
good luck
|
|
|
|
|
Thank you very much for your comment. I will try to do that, but if it is not working I will do it in a separate procedure then make a call to that procedure instead.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
First of all, your btn name and the Handles control name really should reference the same button in the second click handler you have shown above.
Second, if you need to run a common set of code from two or more control event handlers, you should move the code out of the control event handler and into a separate procedure. In the long run this will make your code much clearer and more maintainable. Calling control events from other control events is not a particularly good practice in terms of design.
I would rewrite the above code as:
----------------------------------------------------------------------------------------------
Private Sub btnEvalGuide_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnEvalGuide.Click
' the code work here.
' ...
'Call common procedure here
DoMyCommonProc()
End Sub
Private Sub btnIntVuDmExp_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnIntVuDmExp.Click
' the code work here.
' ...
'Call common procedure here
DoMyCommonProc()
End Sub
Private Sub DoMyCommonProc()
'Put common code in this procedure and call from both click events
End Sub
----------------------------------------------------------------------------------------------
Robert
|
|
|
|
|
Thank you very much for your comment. I will consider this opinion if there is no more choice.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
i m trying to make a vcd cutter like software in vb.net. i m using a binery reader to split the files.if i split the file from begnige it's playes fine but if i try to split it from sommeware middle the the clip is not working.can any one help me in this
|
|
|
|
|
The clip is not working because the beginning of the file has information about Audio and Video codecs, compression ratios, bit rates, etc.
If the player cannot find this information at the beginning of the file, it won't be able to play it.
You'll need to research the format specifications for whatever format(s) you want to support so that you can properly format your output, or find a third-party library to handle this part of the proccess.
|
|
|
|
|
i know that much but can u tell me how i can format the output of me file or any persone who can help me on this
|
|
|
|
|
Hi,
I'm trying to do something very simple, however I seem to going rouund in circles!
1. I have an Array which is loaded from a file, I then load it into a DataTable, at the same time adding Column names.
2. I create a DataView from the Datatable.
3. I asign the DataView to a Datagrid using Datagrid.DataSource = DataView
4. Run, everything works fine.
The issue...
I want to change the size of the columns and hide some occasionally. I tried using DatagridTableStyles are per several submissions on the web, but it won't work.
Any ideas?
Is there a simple way of doing this?
|
|
|
|
|
Using DataGridTableStyles IS the simple way of doing it, and as it happens, the only way.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok, thanks for that at least I'm in the right place.
In that case then please can you help me to understand when the following code doesn't work, it's probably something simple...
I'd really appreciate some assistance...thanks
What Happens > All the data loads fine, the Datagrid1 formating works ok, but the columns are not adopting the table styles I created!
coding...
-->Step 1 load up 'Product' Array with Data
-->Step 2 load up Column collection...
Private Sub LoadColumnCollection()
productColumnCollection.Add("Level3")
productColumnCollection.Add("Level4")
productColumnCollection.Add("Rep_ITEM")
productColumnCollection.Add("Description")
productColumnCollection.Add("Ext_Description")
productColumnCollection.Add("End_Date")
productColumnCollection.Add("Price_From")
productColumnCollection.Add("Price_To")
productColumnCollection.Add("Price_Comments")
productColumnCollection.Add("RRP")
productColumnCollection.Add("Min_ISP")
productColumnCollection.Add("Max_ISP")
productColumnCollection.Add("ISP%SIP")
productColumnCollection.Add("%Margin")
productColumnCollection.Add("Units")
productColumnCollection.Add("SIP")
productColumnCollection.Add("Pack_Priority")
productColumnCollection.Add("Exculsive")
productColumnCollection.Add("Despatch_Date")
productColumnCollection.Add("ITEM_Code")
productColumnCollection.Add("Lenght_Av.")
productColumnCollection.Add("Unit_EAN")
productColumnCollection.Add("Case_EAN")
productColumnCollection.Add("Outer_EAN")
productColumnCollection.Add("Length")
productColumnCollection.Add("Width")
productColumnCollection.Add("Height")
productColumnCollection.Add("Case_Length")
productColumnCollection.Add("Case_Width")
productColumnCollection.Add("Case_Height")
productColumnCollection.Add("Gross_Weight")
productColumnCollection.Add("H")
productColumnCollection.Add("Pallet_Weight")
productColumnCollection.Add("Cases_Per_Layer")
productColumnCollection.Add("Layers_Per_Pallet")
productColumnCollection.Add("Reason_For_Change")
End Sub
Private Sub LoadColumnNames()
Dim row As Integer
Dim dC As DataColumn
' set product table up...
productTable = New DataTable("Product Table")
' construct table columns and names...
Try
For Each Nm As String In productColumnCollection
dC = New DataColumn(Nm)
dC.DataType = System.Type.GetType("System.String")
productTable.Columns.Add(dC)
Next
Catch
End Try
End Sub
-->Step 3 load up Column names into table...
Private Sub LoadColumnNames()
Dim row As Integer
Dim dC As DataColumn
' set product table up...
productTable = New DataTable("Product Table")
' construct table columns and names...
Try
For Each Nm As String In productColumnCollection
dC = New DataColumn(Nm)
dC.DataType = System.Type.GetType("System.String")
productTable.Columns.Add(dC)
Next
Catch
End Try
End Sub
-->Step 4 load up Dataview...
Friend Sub ViewConstructor()
productTableViewDefault = New System.Data.DataView(productTable)
productTableViewDefault.AllowNew = False
productTableViewDefault.AllowDelete = False
productTableViewDefault.AllowEdit = True
End Sub
--> Step 5 Assign view to Datagrid1...
Datagrid1.Datasource = productTable
--> Step 6 Format Datagrid1...
With DataGrid1
.BackColor = Color.GhostWhite
.BackgroundColor = Color.Lavender
.BorderStyle = BorderStyle.None
.CaptionBackColor = Color.RoyalBlue
.CaptionFont = New Font("Tahoma", 12.0!, FontStyle.Bold)
.CaptionForeColor = Color.Bisque
.CaptionText = "Installed Software"
.Font = New Font("Tahoma", 8.0!)
.ParentRowsBackColor = Color.Lavender
.ParentRowsForeColor = Color.MidnightBlue
.HeaderBackColor = Color.DarkBlue
.HeaderForeColor = Color.White
End With
'set up style...
Dim objDataGridTableStyle As New DataGridTableStyle
Dim objTextCol As New DataGridTextBoxColumn
' set alternate background colour...
objDataGridTableStyle.AlternatingBackColor = Color.WhiteSmoke
' set the mappingname for the DataGridTableStyle...
objDataGridTableStyle.MappingName = "productTable"
'set column 1
objTextCol.MappingName = "Level3"
objTextCol.HeaderText = "Level >3"
objDataGridTableStyle.GridColumnStyles.Add(objTextCol)
'set column 2
objTextCol = New DataGridTextBoxColumn
objTextCol.MappingName = "Level4"
objTextCol.HeaderText = "Level >4"
objDataGridTableStyle.GridColumnStyles.Add(objTextCol)
'final step, add datagridtablestyle to datagrid...
DataGrid1.TableStyles.Add(objDataGridTableStyle)
End of code...
Thanks
|
|
|
|
|
I want my application to send a request to search engine(Yahoo.com ,Excite,Altavista,msn) and the search engine should return the URLs of the top 10 sites that match the keywords I sent to the search engine.
I have found google.com contain an API for developers but the other search engines does not provide a similar API or web service.
Thanks in advance
|
|
|
|
|
And your question is?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
my question is How can I get the top 10 sites that match my request from a search site other than Google
|
|
|
|
|
You'll have to either
1) Write the code for each search engine to parse up the resulting HTML and pull out the information you need.
2) Consult with the search engine to find out if there is some kind of developer interface for you to use. Like Googles...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need to concatenate a one list of wav files with another list
I found a vb program on the net that uses th dos copy command by creating a batch file on the fly. this doesn't seem to work and although concatenates the files (the file size is bigger) when trying to play the wav file it only plays the first file
The filenames are of the following format:
file1 "hey <text of var length>.wav"
file2 "oh <text of var length>.wav"
I want to run a batch list as there are 108 files of each type. The varying length text is the same for the two files that need to be joined.
Cany anyone help?
Terry
|
|
|
|
|
If only it was so easy as copying files together. Unfortunately, it's not. The header of the .WAV file stores information such as bit rate, encoding, channel format, data length, ... This information is not expected in the middle of a .WAV file and is not interpreted as a new .WAV and played, as you've noticed.
You have a couple of problems. First, joining two .WAV files together means you have to read both files, determine that they share the exact same encoding, bit rate, ... what have you... Then write a new header with a new header built to encompass the data from BOTH files, not just one. Write the audio data from the first file, then append the audio data form the second.
Secondly, what if the encoding is different? How about the bit rate? You'll now have to recode the data from the second file to match the encoding of the first. Same with the bit rate...
I would recommend searching for an audio format processing library to take care of this work for you. I would suggest Googling[^] for "audio processing library VB.NET wav".
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the info, that's pretty muuch as I expected the case would be.
Terry
|
|
|
|
|
How can i generate dynamic database fields in crystal reports, pls repla imediately with the help of a sample code
in VB.Net
Jyt
|
|
|
|
|
Dear Friend i have the below string written
and i want to know if could be converted to executable code
"Tree" & "." & "Nodes" & "(" & 0 & ")" & "." & "Nodes" & "." & "Add(" & """0.4""" & ")"
where Tree is a treeview control
i want to add nodes in a complicated treeview and it would be
very easily to me if i could convert such strings as the above
to executable code
ergolabos
|
|
|
|
|
The complexity of the code involved is not worth it. Why on earth could you just use comething like:
Tree.Nodes(someIndexVariable).Nodes.Add("0.4")
It's incredibly easy to build the string you want, but incredibly difficult to convert it to executable code that will work with your TreeView control.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hello,
i tried to use the ExitWindowsEx() WINAPI in Visual Basic 6,
i use Windows XP OS and i want to reboot my pc after some installation (designed in vb). the parameters include 0 for logoff, 1 for shutdown and 2 for reboot.....
if i use 0 (logoff) it works fine, but when i use 1 or 2 .... it wont execute... enters into err handler...
here is the code...
If ExitWindowsEx(2, 0) = 0 Then<br />
MsgBox "The system could not REBOOT the machine. !"<br />
End If
previous to this we need to define the function..
Public Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long)
plz help me...
- thanks,
Basavaraj P.Umadi
|
|
|
|
|