Armin - Start sound problem revived in new thread

J

Jack Sadie

Armin,
Renewing my request for help to have a different Windows Start Sound for
each day of the week.

I have started again completely. Opened a new project called Windows
Application 1 and immediately selected the menu View/Code and entered the
text amended as suggested so that
Form 1.vb* now reads:
Public Class Form1

Private Declare Function sndPlaySound Lib

"winmm.dll" Alias _

"sndPlaySoundA" (ByVal FileName As String, _

ByVal Flags As Integer) As Boolean

Private Sub Form1_Load( _

ByVal sender As System.Object, _

ByVal e As System.EventArgs) _

Handles MyBase.Load

Dim day As Integer

Dim filename As String

day = Weekday(Now, FirstDayOfWeek.System)

filename = "C:\start sound\day" & day & ".wav"

Msgbox(sndPlaySound(filename, 1))



End Sub

End Class

At the foot now there is an error list with 2 errors. The first at line 2
Col 41 reads "String constant expected" and the second at line4 col 1 reads
"Syntax error".

The section at the right headed Data Sources records that my project
currently has no data sources associated and invites me to add New Data
Source and "data bind items etc"
I really feel out of my depth. I'm happy to press on but will be totally
reliant on help if you remain happy to assist.
 
J

Jack Sadie

Armin
Further to your last message on the previous thread, I was aware that an
"exe"or "com" file might be needed, but there was none to be found so
obviously I had not taken whatever action is required to create it. I doubt
its any different now with my latest endeavour. I do not know what you mean
by IDE.
 
A

Armin Zingler

Jack Sadie said:
Armin,
Renewing my request for help to have a different Windows Start Sound
for each day of the week.

I have started again completely. Opened a new project called Windows
Application 1 and immediately selected the menu View/Code and
entered the text amended as suggested so that
Form 1.vb* now reads:


I don't know how the code looks in your Form1.vb because if you paste it
here it is changed. This should work:

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

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

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


End Sub


As I've written in the other thread (I believe I did), I hope you did not
delete the "Windows Forms Designer generated Code" region.

BTW, you should keep answering in the thread you've already started because
otherwise I have to search for it and other people don't know what we are
talking about.


End Sub
 
A

Armin Zingler

Jack Sadie said:
Armin
Further to your last message on the previous thread, I was aware
that an "exe"or "com" file might be needed, but there was none to be
found so obviously I had not taken whatever action is required to
create it. I doubt its any different now with my latest endeavour.

There is a menu Build -> Build project. After that, you should have an exe
file in the 'bin' subfolder of your project.
I do not know what you mean by IDE.

Integrated Development Environment. The thing with the windows and menus
that you use for development. ;-)


Armin
 
J

Jack Sadie

OK !! we're really getting somewhere at last.
Found the .exe file in a subdirectory of .bin and put in start-up folder.
Rebooted and lo and behold! The music she played - correct day too.
Checked that too by re-setting the date and re-booting. Same again
correct music for day selected.
Many thanks are due to you for all that.
However there are still a couple of issues - some people are never satisfied
eh!

1. When the music starts, a dialog flashes on to screen headed Windows
Application1
(which is the name of course) and message reads "True" with an "OK" button
below.
When I press the OK button a new dialog opens which is blank except for the
heading
"Form1" and I can close that with the top right hand "close" button in the
usual way.
I'd like to get rid of all the dialogs if possible - don't mind if they show
briefly but I
don't want to have to delete them manually.

2. The music starts very late in the boot sequence - about 120 seconds after
pressing the re-boot switch as opposed to about 40 seconds with a sound set
via the "Sounds and Audio Devices" icon in Control Panel. Clearly the method
you have used for setting my sounds does not select a sound which is
inserted via the last mentioned. Is it possible to determine the place of
that exe file in the boot sequence? I have the StartupCop program but I
think that merely shows what's present and allows it to be enabled or
disabled.

Anyway so far so good. My grateful thanks.
 
A

Armin Zingler

Jack Sadie said:
OK !! we're really getting somewhere at last.
Found the .exe file in a subdirectory of .bin and put in start-up
folder. Rebooted and lo and behold! The music she played - correct
day too. Checked that too by re-setting the date and re-booting.
Same again correct music for day selected.
Many thanks are due to you for all that.
However there are still a couple of issues - some people are never
satisfied eh!

1. When the music starts, a dialog flashes on to screen headed
Windows Application1
(which is the name of course) and message reads "True" with an "OK"
button below.
When I press the OK button a new dialog opens which is blank except
for the heading
"Form1" and I can close that with the top right hand "close" button
in the usual way.
I'd like to get rid of all the dialogs if possible - don't mind if
they show briefly but I
don't want to have to delete them manually.

You remember that I inserted the msgbox to debug the problem. You can simply
remove it.

If you don't want a Form, you can reduce the application to Sub Main. That's
the sub that is called when the program starts. Add a class to the project
(e.g. named "App") and insert the sub main:

Shared Sub Main

End Sub

Move the code that you currently have in Form_Load into this sub. After
this, you can delete Form1.vb from the project. Afterwards, you will
probably get a message from VB that Sub main isn't found. Doubleclick on the
message in the task list and select App.Main as the new startup object. If
you don't get the message, open the project properties and set Sub Main
there.


2. The music starts very late in the boot sequence - about 120
seconds after pressing the re-boot switch as opposed to about 40
seconds with a sound set via the "Sounds and Audio Devices" icon in
Control Panel. Clearly the method you have used for setting my
sounds does not select a sound which is inserted via the last
mentioned. Is it possible to determine the place of that exe file in
the boot sequence? I have the StartupCop program but I think that
merely shows what's present and allows it to be enabled or disabled.

I don't know how you can influence the order of started applications at
startup.


Armin
 
J

Jack Sadie

So sorry - now down with 'flu.
Just got up to let you know I haven't given up yet.
 
J

Jack Sadie

Armin, Back again and thanks for your good wishes.

During my sickness I did a lot of thinking about what I'm trying to achieve
and believe there may be a MUCH better approach if you remain interested.
In order to get the timing right, it makes sense to use the Windows control
panel to set the start sound.
Therefore what I'd like to design is a routine which can be set in the start
up folder and which will:-

1. Delete FilenameX in Filepath\FolderB
2. If the day is Monday, copy File1 from Filepath\FolderA to
Filepath\FolderB with the new name FilenameX, or
3. If the day is Tuesday, copy File2 from Filepath\FolderA to
Filepath\FolderB with the new name FilenameX, or..........
4. ........etc for each day of the week.

In that way the file will be changed daily, ready for the next day's
startup, and it does not matter at what stage in the boot sequence it is
executed. I expect it will execute after that day's sound has been invoked,
but it would not really matter if it executed earlier.

Does that make sense ?
TIA =:>)~ (~ is because I have a beard!)
 
A

Armin Zingler

Jack Sadie said:
Armin, Back again and thanks for your good wishes.

I hope you feel better now. :)
During my sickness I did a lot of thinking about what I'm trying to
achieve and believe there may be a MUCH better approach if you
remain interested. In order to get the timing right, it makes sense
to use the Windows control panel to set the start sound.
Therefore what I'd like to design is a routine which can be set in
the start up folder and which will:-

1. Delete FilenameX in Filepath\FolderB
2. If the day is Monday, copy File1 from Filepath\FolderA to
Filepath\FolderB with the new name FilenameX, or
3. If the day is Tuesday, copy File2 from Filepath\FolderA to
Filepath\FolderB with the new name FilenameX, or..........
4. ........etc for each day of the week.

In that way the file will be changed daily, ready for the next day's
startup, and it does not matter at what stage in the boot sequence
it is executed. I expect it will execute after that day's sound has
been invoked, but it would not really matter if it executed earlier.

Does that make sense ?

Not to me. Sorry. :) You are saying "next day's startup" - what if it's
started 3 days later? Wrong sound. I think the way you did it before is much
more straightforward: Play the sound for the day when it's started.

TIA =:>)~ (~ is because I have a beard!)

From today I don't have one anymore. :) (but I do have a nose ;o)


Armin
 
J

Jack Sadie

Ok., Armin.

Well thanks to you that works now already, except I need to delete the Form.
And
hopefully I should be able to achieve that by myself now.
Thanks for having stayed with me. {:>)~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top