|
Yep. I spotted that after I had posted the Q.
|
|
|
|
|
I used AxShockwaveFlash Object to play first.swf file, i wanna play second.swf when first.swf complete so how can i get the total completion time period of flash file, means each swf file must play only once then load next swf file..
Can anyone give me suggestion 4 this
Thanks with annticaptions
Unless u don't give ur hundred percent whatever u r doning till there is no result of ur work...
|
|
|
|
|
I have some code that reads email items and their attachments and then moves the mail item to a "Processed" folder in the users mail box. In general it works ok, but if the attachment in a file type that is not recognised (this raises an error), I want to identify the mail item and move it to a different folder. When I debug my code, the appropriate catch statements seem to get called and the flags set correctly, but when I get the part of the code that moves the mail items, the one that raised the error gets moved into the "Processed" folder and not the "Failed" folder.
Can anyone see what I am doing wrong?
In the code below, theMailItem is a structure.
I.E.
<br />
Public Structure TheMailItem<br />
Dim theItem As MailItem<br />
Dim theMove As Boolean<br />
Dim theFail As Boolean<br />
End Structure<br />
For Each theMailItem In theMailItems
Try
ReadMailItem(theMailItem.theItem)
Catch ex As InvalidCastException
theMailItem.theFail = True
theMailItem.theMove = False
Catch ex As NullReferenceException
theMailItem.theFail = True
theMailItem.theMove = False
Catch ex As System.Exception
theMailItem.theFail = True
theMailItem.theMove = False
End Try
Next
For Each theMailItem In theMailItems
'Move any processed items
If theMailItem.theMove = True Then
theMailItem.theItem.Move(theMoveFolder)
End If
'Move any fail items
If theMailItem.theFail = True Then
theMailItem.theItem.Move(theFailedFolder)
End If
Next
|
|
|
|
|
I love it "programming by error", perfect example, try something and when it fails try something else, when the error trap fails (possibly becasue the variable is now out of scope) ask on CP.
Where do these ideas come from, you KNOW there may be errors, you know where they are, you know what causes them, for all thats sensible TEST the attachment BEFORE you attempt to move it, don't rely on your error handling to do your job for you.
Sorry for the rant....
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I would love to test the attachment before attempting to read it (I want to move the whole email-not the attachment). I just can't find any information about how to test it. If you know of any good Outlook API programming resources I would be grateful. I can't find any and MSDN is just about worthless.
Testing first (which I agree would be the best thing) is not really the question. The question is why do the flags seem to be set in the catch statements but revert to the default settings.
The variable is not out of scope (I think). The catch block seems to set the flags ok and when I step through it the email item is still set.
(I have stripped out some of the other parts of the catch statements and also want to develop this up so that it moves files that throw different exceptions to different folders - I just wanted to keep my question as simple as possible).
Also, I don't mind the rant. I realise that I am opening up for criticism of my code when I post here. I don't do it without looking everywhere I can for an answer first.
|
|
|
|
|
RCoate wrote: opening up for criticism of my code when I post here
I don't have an issue with your code - seems Ok to me, I just hate the use of the exception handler as any thing but a disaster trap.
RCoate wrote: I would love to test the attachment before attempting to read it
I'm pretty sure you can save the attachment via the API. This would then let you inspect the attributes of the file. I know this is a kludge but may be an option.
I also seem to remember there was an array of attachments within the mail object that can probably be inspected directly.
RCoate wrote: good Outlook API programming resources
Sorry - I hate Outlook as much as the next bloke so my knowledge is limited.
I realise you want to move the whole message but you have identified the problem that is stopping you so now you need to handle the attachment issue before attempting to move the mail object.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I love it "programming by error"
Yes, very lovely
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
The problem you are having is caused by the way structures are handled. When you declare a class, you essentially pass around a pointer and code like
Dim A as new SomeObject
A.SomeProperty = 3
Dim B As SomeObject = A
B.SomeProperty = 5
Console.WriteLine(A.SomeProperty)
would output 5. However with structures, you are actually making copies of the data. So for your code, the first loop makes a copy of the items in the array, then modifies the properties of the *copies* in the exception handlers. You have two options. One is to change TheMailItem to a class, which is probably a better option if MailItem (the type of one of the properties on TheMailItem) is a class. The other is to combine the loops into a single loop. Here's some code to show that structures really are copied:
Sub Main()
Dim items(10 - 1) As CopyTest
Dim i As Integer
Dim ct As CopyTest
For i = 0 To items.Length - 1
items(i) = New CopyTest
items(i).Original = i
items(i).Modified = i
Next
Console.WriteLine("Original Values:")
For Each ct In items
Console.WriteLine("Original: {0} Modified: {1}", _
ct.Original, ct.Modified)
Next
Console.WriteLine("Modifications in progress:")
For Each ct In items
ct.Modified = ct.Modified * 3
Console.WriteLine("Original: {0} Modified: {1}", _
ct.Original, ct.Modified)
Next
Console.WriteLine("After Modifications:")
For Each ct In items
Console.WriteLine("Original: {0} Modified: {1}", _
ct.Original, ct.Modified)
Next
Console.ReadKey()
End Sub
Private Structure CopyTest
Public Original As Integer
Public Modified As Integer
End Structure
|
|
|
|
|
Thanks Gideon.
That makes sense.
I changed the structure to a class and it is working now.
modified on Thursday, July 3, 2008 12:25 AM
|
|
|
|
|
I'm stumped on something that should be simple, but.....
I've written a VBscript to create a folder on an IOMega NAS box using objFSO.CreateFolder, and copy some files to it for backup. It runs on a server using Win2003R2. The NAS box is mapped to a local drive letter on this server.
I use cscript to run the script, fired off by the scheduler at night, under an Administrator user ID.
The script works fine in debug mode.
If I execute the script from a Run|cmd command line, it works fine.
When kicked off by the scheduler, it always fails on the CreateFolder method with a 76 error (path not found).
But if I open the scheduler, right click on the job and select "Run", it runs the job with no problems and completes successfully!
I've inserted some debug code before the CreateFolder, checking for FolderExists on the NAS box and that is always successful. The first hint of trouble is the 76 error on the CreateFolder method.
Here's some of the code. "x" is the mapped drive.
BTW: all of the code referencing "NAS disks to spinup" was added to get around this 76-error problem, under the assumption that idled disks were the culprit; none of it helped.
Const Backupfolder = "x:\Data Backups"
.
.
.
' Checking to see if NAS disks are still spinning
If objFSO.FolderExists(Backupfolder) Then i=1
writelog ("check that NAS disks are spinning: err.num: " & Err.Number & " " & Err.Description)
errHandler ("checking if NAS disks are spinning")
' Generate today's directory name in the format yymmdd
strmonth = month(date)
if strmonth < 10 then strmonth = "0" & strmonth
strday = day(date)
if strday < 10 then strday = "0" & strday
todaysfolder = right(year(date),2) & strmonth & strday
' Now create the full pathname to today's backup folder
todayspath = Backupfolder & "\" & todaysfolder
' Create todays backup folder
If objFSO.FolderExists(todayspath) Then
Set objbkupFolder = objFSO.GetFolder(todayspath)
writelog(todayspath & " already exists!")
Else
writelog("Creating folder " & todayspath)
Err.Clear
Set objbkupFolder = objFSO.CreateFolder(todayspath)
If Err.Number <> 0 Then
writelog ("Waiting 15 seconds for NAS disks to start. Err: " & Err.Number & " " & Err.Description)
Err.Clear
objbkupFolder = nothing
Wscript.Sleep 15000 'Wait 15 seconds for NAS disks to spin up
Set objbkupFolder = objFSO.CreateFolder(todayspath)
If Err.Number <> 0 Then
errHandler (" trying to create folder " & todayspath)
abendscript
End If
End If
End If
Anybody have any ideas on this?
Jeff
|
|
|
|
|
It doesn't work because the drive mapping doesn't exist under the scheduler's user session. You have to provide code in the script for mapping the drive, or just skip the drive mapping and recode the script to use UNC paths instead.
|
|
|
|
|
Changed to UNC addressing. Works like a champ now. Thanks
|
|
|
|
|
when working wit winservice will it be better to use timer or thread
|
|
|
|
|
The two are completely different concepts that do not apply to the same thing. What are you trying to do??
|
|
|
|
|
i am trying to manipulate database. insert, update and select using winservice programme
|
|
|
|
|
Hi,
if it has to work in the background and is not related to time, just use one or more extra threads.
if it is time related (e.g. a periodic action), use a timer.
|
|
|
|
|
|
I've been given a project to run/update a spreadsheet using VBA/Excel. When I try to run the macros I keep getting the following erro:
Run-time error '91':
Object variable or With Bock cariable not set
I have no idea what to do and I have not used VBA!
Here is where the trouble starts**:
Ensure all Active projects are in the "All" Sheet
With g_wksIOProjects
**For lngRow = 2 To .UsedRange.Rows.Count
If .Cells(lngRow, 28).Value = "COMMITTED" And _
.Cells(lngRow, 5).Value <> "Execution (PEM) - On hold" Then
If InSheet(g_wksALL, 2, .Cells(lngRow, 1).Value) = False Then
Call WriteMessage("Committed project missing from 'All', " & _
.Cells(lngRow, 1).Value & ": " & .Cells(lngRow, 3).Value, Mess.Critical)
End If
End If
If .Cells(lngRow, 28).Value <> "COMMITTED" And _
.Cells(lngRow, 28).Value <> "CANCELLED" And _
.Cells(lngRow, 28).Value <> "CLOSE" And _
.Cells(lngRow, 28).Value <> "NOT SUBMITTED" And _
.Cells(lngRow, 14).Value > 50 Then
If InSheet(g_wksALL, 2, .Cells(lngRow, 1).Value) = False Then
Call WriteMessage("Project with significant recorded effort missing from 'All', " & _
.Cells(lngRow, 1).Value & ": " & .Cells(lngRow, 3).Value & _
", Hours = " & .Cells(lngRow, 14).Value, Mess.Critical)
End If
End If
Next lngRow
End With
|
|
|
|
|
Sounds like .UsedRange.Rows.Count is not set when you run your code.
Do you need to select your range first?
|
|
|
|
|
What is the Worksheet name you are referencing?
With ActiveSheet
For lngRow = 2 To .UsedRange.Rows.Count
....
Next
End With
Try this with the workseet active.
I don't speak Idiot - please talk slowly and clearly
|
|
|
|
|
Is there a big difference between vb6 and vb.net as far as coding and design?
|
|
|
|
|
You simply can not compare them...
The only resemblance is the sintaxe every thing else is completly diferent
Sérgio Lima
Many people would sooner die than think; In fact, they do so.
- Bertrand Russell
|
|
|
|
|
|
There are differences between VB6 and VB.NET. VB6 has been dead, and unsupported by Microsoft since about March 2005. VB.NET is more closer to be really object oriented than VB6.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
VB6 is a muddled mess of a language which is saddled with oodles of quirks which were designed to make it somewhat compatible with QuickBasic and QBASIC, which were in turn designed to be compatible with the original IBM PC Cassette BASIC. Although it "looks" object-oriented, it lacks features like inheritance which are necessary to make real object-oriented programming possible. Further, as a result of its Cassette BASIC roots, many object methods have strange and bizarre variations in syntax which cannot be mimicked with user-defined functions. For example, to draw a box on the printer,
Printer.Line(10,10)-(20,20),0,BF
The use of two coordinate pairs, separated by a dash, and the use of the literal characters "BF" (block fill) without any string delimiter, are both perfectly fine syntax in an interpreted language (like Cassette Basic). They're not really any harder to parse than would be "LINE 10,10,20,20,0,2" (the "3" being "BF") and they're easier to read, but syntax line that makes it impossible to create a function that behaves like the "Line" function.
|
|
|
|
|