473,513 Members | 2,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Very, very, very new user needs help.

I am using Windows XP and I have found out how to substitute my own wav
sound for the Microsoft default sound when my computer starts, but now I
want to go a step further. I have created 7 different wave files

(C:\Start sound\day1.wav to C:\Start sound\day7.wav respectively)

and want to have a different one open according to the day of the week - the
"day1.wav" opening on Mondays and the "day2.wav" on Tuesdays and so on.

I have downloaded Visual Basic Express edition but I need to have a routine
created which I don't have the expertise to do.
I was very kindly given the following routine in a VB6 ng but because it
won't work in the Express Edition, they advised me to try a dotnet group for
the correct code. I have included it below because it just might be easily
amended by someone who is familiar but it may need to be completely
re-composed.

Can any kind person assist or point me in the right direction if this is the
wrong ng.
Thanks so much.
Option Explicit
Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal FileName As String, _
ByVal Flags As Long) As Long
Dim myDate As String

Private Sub Form_Load()

myDate = Format(Now, "dddd")
Debug.Print myDate
Select Case myDate
Case "Monday"
Call sndPlaySound("C:\start sound\day1.wav", 1)
Case "Tuesday"
Call sndPlaySound("C:\start sound\day2.wav", 1)
Case "Wednesday"
Call sndPlaySound("C:\start sound\day3.wav", 1)
Case "Thursday"
Call sndPlaySound("C:\start sound\day4.wav", 1)
Case "Friday"
Call sndPlaySound("C:\start sound\day5.wav", 1)
Case "Saturday"
Call sndPlaySound("C:\start sound\day6.wav", 1)
Case "Sunday"
Call sndPlaySound("C:\start sound\day7.wav", 1)
End Select
End Sub
--
Regards, Jack Sadie
ja************@yahooREMOVE.co.uk

Dec 29 '05 #1
10 1180
Jack,

In VB 2005 there are more methods to play a wav file.

You can use DirectX
You can use My.Computer.Audio.Play(fileName)
http://msdn2.microsoft.com/en-us/library/cf1shcah.aspx

You can do it in the way as you see in that VB6 sample, because that in VB6
a long is 32bits you have to change that "long in "Int32".

And there is even another method, I have to search for it, it comes not
direct in my mind, however because that I assume that you will use that
Audio.Play (because you should try to avoid using Win32 API's and DirectX is
the hard way to go), I don't do that.

I hope this helps,

Cor
Dec 29 '05 #2
"Jack Sadie" <ja*******@btinternet.com> schrieb
I am using Windows XP and I have found out how to substitute my own
wav sound for the Microsoft default sound when my computer starts,
but now I want to go a step further. I have created 7 different wave
files

(C:\Start sound\day1.wav to C:\Start sound\day7.wav respectively)

and want to have a different one open according to the day of the
week - the "day1.wav" opening on Mondays and the "day2.wav" on
Tuesdays and so on.

I have downloaded Visual Basic Express edition but I need to have a
routine created which I don't have the expertise to do.
I was very kindly given the following routine in a VB6 ng but
because it won't work in the Express Edition, they advised me to try
a dotnet group for the correct code. I have included it below
because it just might be easily amended by someone who is familiar
but it may need to be completely re-composed.

Can any kind person assist or point me in the right direction if
this is the wrong ng.
Thanks so much.
Option Explicit
Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal FileName As String, _
ByVal Flags As Long) As Long

Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal FileName As String, _
ByVal Flags As Integer) As Boolean

Dim myDate As String

Private Sub Form_Load()

myDate = Format(Now, "dddd")
Debug.Print myDate
Select Case myDate
Case "Monday"
Call sndPlaySound("C:\start sound\day1.wav", 1)
Case "Tuesday"
Call sndPlaySound("C:\start sound\day2.wav", 1)
Case "Wednesday"
Call sndPlaySound("C:\start sound\day3.wav", 1)
Case "Thursday"
Call sndPlaySound("C:\start sound\day4.wav", 1)
Case "Friday"
Call sndPlaySound("C:\start sound\day5.wav", 1)
Case "Saturday"
Call sndPlaySound("C:\start sound\day6.wav", 1)
Case "Sunday"
Call sndPlaySound("C:\start sound\day7.wav", 1)
End Select
End Sub


Private Sub Form_Load()
dim day as integer
dim filename as string

day = Weekday(Now, FirstDayOfWeek.System)
filename = "C:\start sound\day" & day & ".wav"
sndPlaySound(filename, 1)

End Sub
Armin
Dec 29 '05 #3
"Jack Sadie" <ja*******@btinternet.com> schrieb:
I am using Windows XP and I have found out how to substitute my own wav
sound for the Microsoft default sound when my computer starts, but now I
want to go a step further. I have created 7 different wave files

(C:\Start sound\day1.wav to C:\Start sound\day7.wav respectively)


Untested (requires .NET 2.0 (VS 2005)):

\\\
Imports System.Media
....
Dim FileName As String
Select Case Now.DayOfWeek
Case DayOfWeek.Monday
FileName = "Monday.wav"
Case DayOfWeek.Tuesday
FileName = "Tuesday.wav"
Case DayOfWeek.Wednesday
...
Case DayOfWeek.Thursday
...
Case DayOfWeek.Saturday
...
Case DayOfWeek.Sunday
...
End Select
Dim Player As New SoundPlayer( _
Path.Combine(My.Application.Info.DirectoryPath, FileName) _
)
Player.Play()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Dec 29 '05 #4
"Armin Zingler" <az*******@freenet.de> schrieb
day = Weekday(Now, FirstDayOfWeek.System)


Addition: Don't believe the online help to 'Weekday'. It says the return
value of Weekday is equal to the value of the FirstDayOfWeek enumeration.
That's wrong. If it was true, the return type of Weekday could be
FirstDayOfWeek, not Integer. Actually, Weekday returns the number of the day
in the week, i.e. 1 for the 1st day, 2 for the 2nd, 3 for the 3rd etc. If
Monday is the first day, it returns 1 for Monday. If Sunday is the first day
of the week, it returns 1 for Sunday.
Armin

Dec 29 '05 #5
THANKS TO ARMIN, COR AND HERFRIED.
I appreciate the trouble each of you has taken. I'm not certain I quite
understand how to employ (or deploy) any of your answers at this stage.
However I shall be experimenting and will report back in due course.
For starters in the meantime :-

Armin,
Sorry but I really am so newbie I don't even know where to start !

Do I just open a new project, click on View/code and enter the following
between "Public Class Form1" and " End Class":-

Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal FileName As String, _
ByVal Flags As Integer) As Boolean

Private Sub Form_Load()
dim day as integer
dim filename as string

day = Weekday(Now, FirstDayOfWeek.System)
filename = "C:\start sound\day" & day & ".wav"
sndPlaySound(filename, 1)

End Sub

After that what do I do?
(Are you sorry you started to help me!! =:>( "
--
Regards, Jack Sadie
ja************@yahooREMOVE.co.uk
"Jack Sadie" <ja*******@btinternet.com> wrote in message
news:wZ******************************@pipex.net...
I am using Windows XP and I have found out how to substitute my own wav
sound for the Microsoft default sound when my computer starts, but now I
want to go a step further. I have created 7 different wave files

(C:\Start sound\day1.wav to C:\Start sound\day7.wav respectively)

and want to have a different one open according to the day of the week -
the "day1.wav" opening on Mondays and the "day2.wav" on Tuesdays and so
on.

I have downloaded Visual Basic Express edition but I need to have a
routine created which I don't have the expertise to do.
I was very kindly given the following routine in a VB6 ng but because it
won't work in the Express Edition, they advised me to try a dotnet group
for the correct code. I have included it below because it just might be
easily amended by someone who is familiar but it may need to be completely
re-composed.

Can any kind person assist or point me in the right direction if this is
the wrong ng.
Thanks so much.
Option Explicit
Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal FileName As String, _
ByVal Flags As Long) As Long
Dim myDate As String

Private Sub Form_Load()

myDate = Format(Now, "dddd")
Debug.Print myDate
Select Case myDate
Case "Monday"
Call sndPlaySound("C:\start sound\day1.wav", 1)
Case "Tuesday"
Call sndPlaySound("C:\start sound\day2.wav", 1)
Case "Wednesday"
Call sndPlaySound("C:\start sound\day3.wav", 1)
Case "Thursday"
Call sndPlaySound("C:\start sound\day4.wav", 1)
Case "Friday"
Call sndPlaySound("C:\start sound\day5.wav", 1)
Case "Saturday"
Call sndPlaySound("C:\start sound\day6.wav", 1)
Case "Sunday"
Call sndPlaySound("C:\start sound\day7.wav", 1)
End Select
End Sub
--
Regards, Jack Sadie
ja************@yahooREMOVE.co.uk


Dec 29 '05 #6
"Jack Sadie" <ja*******@btinternet.com> schrieb
THANKS TO ARMIN, COR AND HERFRIED.
I appreciate the trouble each of you has taken. I'm not certain I
quite understand how to employ (or deploy) any of your answers at
this stage. However I shall be experimenting and will report back in
due course. For starters in the meantime :-

Armin,
Sorry but I really am so newbie I don't even know where to start !
You're welcome!
Do I just open a new project, click on View/code and enter the
following between "Public Class Form1" and " End Class":-

Yes - but leave the "Windows forms designer generated code" in place. ;)

Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal FileName As String, _
ByVal Flags As Integer) As Boolean

Private Sub Form_Load()
dim day as integer
dim filename as string

day = Weekday(Now, FirstDayOfWeek.System)
filename = "C:\start sound\day" & day & ".wav"
sndPlaySound(filename, 1)

End Sub

After that what do I do?
Start to see if it works. Did you try? Did it work? If not, was there an
error? If yes, when compiling or at run-time (errors @ run-time are called
'Exceptions' now). If you get an exception, what's the message?
(Are you sorry you started to help me!! =:>( "


No, I don't feel sorry. :-)
Armin

Dec 29 '05 #7
ok Armin
Entered the code. Couldn't see how to save it so I decided to close and it
then asked if I wanted to save, so I did so in the folder offered :-
F:\Visual Studio 2005\Projects\StartSound Project\Start Sound Project.sln

I then shut down and re-started my computer but there was no sound played,
so I obviously haven't set up correctly yet.
I then re-opened the project and pressed F5, which I believe starts the
program running so that any errors are displayed. None showed, so I have
nothing to more to report.
Thanks for keeping with me.
--
Regards, Jack Sadie
ja************@yahooREMOVE.co.uk
"Armin Zingler" <az*******@freenet.de> wrote in message
news:uD**************@TK2MSFTNGP11.phx.gbl...
"Jack Sadie" <ja*******@btinternet.com> schrieb
THANKS TO ARMIN, COR AND HERFRIED.
I appreciate the trouble each of you has taken. I'm not certain I
quite understand how to employ (or deploy) any of your answers at
this stage. However I shall be experimenting and will report back in
due course. For starters in the meantime :-

Armin,
Sorry but I really am so newbie I don't even know where to start !


You're welcome!
Do I just open a new project, click on View/code and enter the
following between "Public Class Form1" and " End Class":-

Yes - but leave the "Windows forms designer generated code" in place. ;)

Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal FileName As String, _
ByVal Flags As Integer) As Boolean

Private Sub Form_Load()
dim day as integer
dim filename as string

day = Weekday(Now, FirstDayOfWeek.System)
filename = "C:\start sound\day" & day & ".wav"
sndPlaySound(filename, 1)

End Sub

After that what do I do?


Start to see if it works. Did you try? Did it work? If not, was there an
error? If yes, when compiling or at run-time (errors @ run-time are called
'Exceptions' now). If you get an exception, what's the message?
(Are you sorry you started to help me!! =:>( "


No, I don't feel sorry. :-)
Armin

Dec 29 '05 #8
"Jack Sadie" <ja*******@btinternet.com> schrieb
I then shut down and re-started my computer but there was no sound
played, so I obviously haven't set up correctly yet.
Did you add your application to the autostart menu?
I then re-opened the project and pressed F5, which I believe starts
the program running so that any errors are displayed. None showed,
so I have nothing to more to report.
Thanks for keeping with me.


Change the line from
sndPlaySound(filename, 1)
to
Msgbox(sndPlaySound(filename, 1))

Start the application again. Do you get a message saying "True" or "False"?

Armin

Dec 29 '05 #9
Tried to add application to start menu, but trouble is I don't really know
which file to add. Could it be one called WindowsApplication1.vbproj ?
That's the one I used.

Changed line as requested - no message true or false.

Rebooted but still no sound. I think I may delete all and start again taking
more trouble to record file names and their location.
In any case I'm leaving London tomorrow for a couple of days to Stratford on
Avon to see some plays at the Shakespeare Theatre.
I'll post back on my return and, if you have no objection Armin (email me
if you would prefer no direct contact), will send an email to advise you at
that time.
Meanwhile Happy New Year to all.
--
Regards, Jack Sadie
ja************@yahooREMOVE.co.uk
"Armin Zingler" <az*******@freenet.de> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
"Jack Sadie" <ja*******@btinternet.com> schrieb
I then shut down and re-started my computer but there was no sound
played, so I obviously haven't set up correctly yet.


Did you add your application to the autostart menu?
I then re-opened the project and pressed F5, which I believe starts
the program running so that any errors are displayed. None showed,
so I have nothing to more to report.
Thanks for keeping with me.


Change the line from
sndPlaySound(filename, 1)
to
Msgbox(sndPlaySound(filename, 1))

Start the application again. Do you get a message saying "True" or
"False"?

Armin

Dec 29 '05 #10
"Jack Sadie" <ja*******@btinternet.com> schrieb
Tried to add application to start menu, but trouble is I don't
really know which file to add. Could it be one called
WindowsApplication1.vbproj ? That's the one I used.

I thought you know that applications are Exe files. Add a link to
WindowsApplication1.exe (it's in the 'bin' sub folder of your project) to
the start menu, but before doing this I suggest to solve the problem. If it
doesn't work in the IDE, it also won't from the start menu.
Changed line as requested - no message true or false.
I missed an important point. Change the line
Private Sub Form_Load()
to
Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load

Now it should work. Don't forget to build the exe before adding it to the
start menu, but this is done anyway if you first test it in the IDE.
Rebooted but still no sound. I think I may delete all and start again
taking more trouble to record file names and their location.
In any case I'm leaving London tomorrow for a couple of days to Stratford
on Avon to see some plays at the Shakespeare Theatre.


Have a nice time. :-)
Armin

Dec 31 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
9640
by: Steven O. | last post by:
I am seeking some kind of tool that I can use for GUI prototyping. I know how to use Visual Basic, but since a lot of software is being coded in Java or C++, I'd like to learn a Java or C++ -based...
3
1668
by: Martin Lacoste | last post by:
Wondering if people have suggestions as to good reference sources for Access 2000 for an (almost..) intermediate user? It appears as though books along the lines of 'Access for Dummies' are way...
16
2385
by: Durumdara | last post by:
Hi ! I have a problem. I have a little tool that can get data about filesystems and wrote it in python. The main user asked me a GUI for this software. This user is needed a portable...
8
6605
by: John | last post by:
Is there any special code I have to write to log event to Security Event Log? The following code give me "Very Easy Question, How to write log to SECURTY Event Log? Please help" Error // Create...
10
5868
by: Peter Duniho | last post by:
This is kind of a question about C# and kind of one about the framework. Hopefully, there's an answer in there somewhere. :) I'm curious about the status of 32-bit vs 64-bit in C# and the...
1
1585
by: flutetones | last post by:
http://67.189.52.24/~metafusionserver/public_html/training.php Here is a link to my server. I have an issue that doen't make sense. What's hapening is this . . . What's going right . . .
13
1693
by: Jack B | last post by:
I'm using Access 2002 to create a database for a small opera company that my wife is involved in, and I'm more than a bit rusty because I haven't created a new Access database since about 1999. ...
1
1535
by: shmodi | last post by:
Hi All, I am new here and want to get some help for speeding up and resolving IE issue while creating tree using ajax. My tree contains radio buttons at each level and I am getting all tree...
1
1451
by: 6655326 | last post by:
Newbi needs a very small help, thank you very much. Hello everyone and thank you very much for your time. I Have a small db for invoicing and on my form (with a subform) there is a CANCEL...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.