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 _
"sndPlaySou ndA" (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 10 1207
Jack,
In VB 2005 there are more methods to play a wav file.
You can use DirectX
You can use My.Computer.Aud io.Play(fileNam e) 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
"Jack Sadie" <ja*******@btin ternet.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 _ "sndPlaySou ndA" (ByVal FileName As String, _ ByVal Flags As Long) As Long
Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
"sndPlaySou ndA" (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(fi lename, 1)
End Sub
Armin
"Jack Sadie" <ja*******@btin ternet.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.Monda y
FileName = "Monday.wav "
Case DayOfWeek.Tuesd ay
FileName = "Tuesday.wa v"
Case DayOfWeek.Wedne sday
...
Case DayOfWeek.Thurs day
...
Case DayOfWeek.Satur day
...
Case DayOfWeek.Sunda y
...
End Select
Dim Player As New SoundPlayer( _
Path.Combine(My .Application.In fo.DirectoryPat h, FileName) _
)
Player.Play()
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
"Armin Zingler" <az*******@free net.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
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 _
"sndPlaySou ndA" (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(fi lename, 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*******@btin ternet.com> wrote in message
news:wZ******** *************** *******@pipex.n et... 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 _ "sndPlaySou ndA" (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
"Jack Sadie" <ja*******@btin ternet.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 _ "sndPlaySou ndA" (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(fi lename, 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
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\S tartSound 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*******@free net.de> wrote in message
news:uD******** ******@TK2MSFTN GP11.phx.gbl... "Jack Sadie" <ja*******@btin ternet.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 _ "sndPlaySou ndA" (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(fi lename, 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
"Jack Sadie" <ja*******@btin ternet.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(fi lename, 1)
to
Msgbox(sndPlayS ound(filename, 1))
Start the application again. Do you get a message saying "True" or "False"?
Armin
Tried to add application to start menu, but trouble is I don't really know
which file to add. Could it be one called WindowsApplicat ion1.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*******@free net.de> wrote in message
news:uX******** ******@tk2msftn gp13.phx.gbl... "Jack Sadie" <ja*******@btin ternet.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(fi lename, 1) to Msgbox(sndPlayS ound(filename, 1))
Start the application again. Do you get a message saying "True" or "False"? Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 tool.
Back when I took my Java and C++ classes (two or three years ago), the
available tools -- at least the ones I could find -- were still not as
easy, not as "drag-and-drop", as Visual Basic. Has that changed?
Is there some software out...
|
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 too basic
for my needs. Or would I be best to continue to root around the
internet and this newsgroup? I really would like a book I can refer
to, however...
To give a better idea as to the level I'm looking at..
- queries are generally not a...
|
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 program, so I create this kind of the
software with Py2Exe.
|
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 an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = "Security";
// Write an informational entry to the event log.
myLog.WriteEntry("Writing warning to event log.",
|
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 framework
classes. The specific example I'm running into is with respect to byte
arrays and the BitConverter class. In C# you can create arrays larger than
2^32, using the overloaded methods that take 64-bit parameters. But as near
as I can tell,...
| |
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 . . .
|
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. So, I will probably have quite a
few questions as I go through this, and hopefully this group will help me
out.
I will be creating this database for someone else to enter the data. I have
a patron table with name, address, email, etc., and I...
|
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 data from database. To speed up, what I am doing is to have tree in session at server side
and whenever ajax needs the tree , it sends appropriate tree key request and get the tree object from server.
My problem starts while processing huge tree....
|
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 button which will just cancel what had been selected or
entered in the form ... here is the code behind the cancel button...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |