|
ahhhh i hate this! :P
i made it work!
thanks anyway
|
|
|
|
|
You should be chuffed you got it working. It also shows the guys on CP that you are willing to work at it yourself, and so will be much more willing to help in the future. Congrats
|
|
|
|
|
thanks! :P
btw i forgot to post a solution!
the only thing why it wasnt working was this part:
winmsga.hwnd = m.HWnd
winmsga.message = m.Msg
winmsga.wParam = m.WParam
winmsga.lParam = m.LParam
winmsga.time = GetMessageTime()
winmsga.x = pos 'just removed CShort()
winmsga.y = (pos >> 16) 'same here
|
|
|
|
|
Please tell me there is a better way to make a pacman like shape move across my form...
Public Class Form1
Dim formSurface As Graphics = Me.CreateGraphics
Dim intLoop As Integer = 0
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
tmrMove.Enabled = True
End Sub
Private Sub tmrMove_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMove.Tick
formSurface.Clear(Color.Black)
Select Case intLoop
Case 0
formSurface.DrawImage(My.Resources.pacmanopen, 10, 75)
Case 1
formSurface.DrawImage(My.Resources.pacmanopen, 11, 75)
Case 2
formSurface.DrawImage(My.Resources.pacmanopen, 12, 75)
Case 3
formSurface.DrawImage(My.Resources.pacmanopen, 13, 75)
Case 4
formSurface.DrawImage(My.Resources.pacmanopen, 14, 75)
Case 5
formSurface.DrawImage(My.Resources.pacmanopen, 15, 75)
End Select
intLoop += 1
End Sub
End Class
Could I possibly do something like...
Case 0 to 100
formSurface.DrawImage(My.Resources.pacmanopen, intX, 75)
and then add 1 to intX each time? I'm open to any ideas...
|
|
|
|
|
yes, you should keep your shape's location in some variable(s). And paint only in the Paint handler.
This article[^] will give you the principles and an example; it is a C# example, but that only constitutes a different syntax, it does not affect the principles.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Alright thanks I'll go look at it right now. I knew there was an easier way..
|
|
|
|
|
The whole approach of using winforms is doomed to failure. You should use XNA, or perhaps WPF, something DirectX based.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Sadly it's for a school project and I have to do it my teachers way...but I'll defiantely look into that stuff for future programs that I do on my own time.
|
|
|
|
|
|
hello!
i wanna add a context menu as "Close CD Tray" in CD drive's context menu.
but i can't only CD drive's context menu.
my context menu is working on all drives as C:, D:, E: so on.
i wanna show it just only on CD drive's context menu.
could u help me pls?
i'll thz u very much....
|
|
|
|
|
|
You will have to check which drive is selected before you create the context menu.
Then when the user clicks the cd drive you show your menu, otherwise you just show the default one.
My advice is free, and you may get what you paid for.
|
|
|
|
|
If you work with a 32bit Windows take loo at this[^]
On a 64b windows it won't work.
|
|
|
|
|
I am having a major problem with a date. (One of the day, month, year kind!) The problem is conversion from a string to a date.
Either I am in perpetual brain fart mode or something odd is going on.
This is a data line being imported
nc,71401286,0,"Thursday, May 20, 2010 01:00:54 UTC",38.8335,-122.8778,1.0,1.80,12,"Northern California"
This is the code that gets the date part and changes it into "dd/MM/yyyy HH:mm:ss"
astrData = strLine.Split(",")
sbldValues = New StringBuilder(strCMD & astrData(QUAKE_ID) & QUOTE & COMMA)
strPartLine = astrData(QUAKE_ID) & COMMA
'Next is the networkID
sbldValues.Append(QUOTE & astrData(NET_SOURCE) & QUOTE & COMMA)
strPartLine &= astrData(NET_SOURCE) & COMMA
'Next is the version which is also a string
sbldValues.Append(QUOTE & astrData(VERSION_NO) & QUOTE & COMMA)
strPartLine &= astrData(VERSION_NO) & COMMA
strEventDate = CDate(Trim(astrData(DATE_PART_1) _
& astrData(DATE_PART_2).Substring(0, astrData(DATE_PART_2).Length - 4))).ToString("dd/MM/yyyy HH:mm:ss")
sbldValues.Append("CONVERT(datetime,'" & strEventDate & "',103)" & COMMA)
If bFileStartDone = False Then
m_strFileStartDate = strEventDate
m_strFileEndDate = strEventDate
bFileStartDone = True
Else
m_strFileEndDate = strEventDate
End If
strPartLine &= strEventDate & COMMA
(COMMA and QUOTE are just constants as I find these easier to read and debug.)
Later on in the code there is this section:
strDate1 = Format(drowData("Date_Time"), "dd/MM/yyyy HH:mm:ss")
strDate2 = astrValues(EVENT_DATE) 'This is already in the right format
If strDate1 <> strDate2 Then
bDifferences = True
intDateDiff = DateDiff(DateInterval.Minute, drowData("Date_Time"), CDate(strDate2))
If intDateDiff > intTimeVariance Then
The second it hits the CDate(strDate2) I get the exception below
System.InvalidCastException was unhandled
Message="Conversion from string "19/05/2010 02:12:54" to type 'Date' is not valid."
Source="Microsoft.VisualBasic"
StackTrace:
at Microsoft.VisualBasic.CompilerServices.Conversions.ToDate(String Value)
My problem is that this runs in a test bed version, and in a compiled exe as part of a windows forms project, but NOT when it is running in a service.
The code is identical - literally - as the class in which this resides is designed to work with the service or the windows program, thus the code file is just copied between the two.
The service is running under 'local system' and I am suspecting the this may have something to do with it, but what? Why should a date conversion behave differently? Have I missed something somewhere?
Edited for a speeling era
|
|
|
|
|
Hi,
my best guess is this: CDate(strDate2) is attempting to parse the string and turn it into a DateTime; as no format is specified, it relies on the regional setting in effect, which one normally sets through the Regional Settings control panel, although it can be overridden by setting the thread's CultureInfo. I assume you did the former; now running as a service, it is not your regional setting that is in effect, it probably is some system default, which may well be an American-style one.
The clean fix is by not using CDate; I'd use DateTime.TryParse or TryParseExact with an explicit format right there. When not communicating with the user, you should always enforce the format your app wants. That is defensive programming: simple and robust.
FWIW: I find your code rather unreadable. I don't like the identifier names much, and all those constants (without their value) obscure the matter even more. So I can not judge the correctness of what was shown.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
All those Caps are irritating.
And the names rather confusing.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
Please see my response to Luc (eyesight), and they please tell me pray how you name and display constants so as to differentiate then from variables? I am always willing to learn.
A la Microsoft
FILE_NOTIFY_CHANGE_FILE_NAME
FILE_NOTIFY_CHANGE_DIR_NAME
FILE_NOTIFY_CHANGE_ATTRIBUTES
FILE_NOTIFY_CHANGE_SIZE
FILE_NOTIFY_CHANGE_LAST_WRITE
FILE_NOTIFY_CHANGE_SECURITY
If that is old fashioned and not used any longer than please enlighten me as to the modern style.
|
|
|
|
|
No Problem with the constants, and now I have read the other response I see the QUOTE and COMMA reasoning.
Fair Dos, but it does look untidy, but I can appreciate why you choose to do it. Those Old Eyes aren't what they used to be!
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
Thanks. No indeed they are not.
|
|
|
|
|
There are larger readability issues; I hope my reply to the OP will hit the nail on the head.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi Luc,
Thanks for the response. I have tried it in American date format and specifying a formatter and none of it seems to work.
Originally as I stated I had the conversions in. I will try the TryParse. You have at least identified for the the fact that it is something to do with the fact that the code is not running as a user, and for that I thank you.
Obviously without the declarations of the constants it is not so readable, but I do it that way to make it more readable. I find that astrData(LATITUDE) is easier to understand when I come back to the code later than astrData(4)
I am curious as to what you don't like about the identifier names? Please enlighten me as I learnt to program over the last 30 years starting in the days of ANSI Basic 1.0 and things have probably changed a bit. My variables always have an identifier for the type, i.e. bGood, strBad, cmdClick etc etc and I was taught that constants should be capitalised and split with and underline to make them readable. It is all named as to it's purpose. i.e QUOTE is a quote ( ' ) and COMMA is a comma ( , ). You might find it a mite curious that I use & QUOTE & COMMA because I have had so many problems debugging this type of thing recently since I find "', very dificult to read in the editor - maybe because I am using Arial font, and the eyesight is not what it used to be, so doing it this way I don't get it wrong. But I am always open to new suggestins to make the code better.
|
|
|
|
|
Coding styles are a very subjective thing. Personally I am with you on this one. I, too learnt to program in ANSI Basic 1.0 and my coding style is exactly like yours, except I don't use constants much.
|
|
|
|
|
Good to know that I am not the only old fart person out there doing it that way! Thanks for telling me that.
|
|
|
|
|
Hi,
your message and code feels very slithery to me; let me explain that. When I try to read and understand a statement such as (I'll pick a simple one here):
strPartLine = astrData(QUAKE_ID) & COMMA
all I am getting from it is: some variable (type unknown, meaning unknown), with a name that suggests it is part of a string (names should describe the essence of the object, not their type), not sure what it will be about (would the app be about earthquakes? hmm, interesting, but I'm not sure here), gets calculated as one element of some array (aha, I've seen that one before, it is the split result), unfortunately I don't know which element gets copied, and some other thing gets appended, its declaration and definition are not available, so I can only hope it is a string (if not VB will execute a sneaky conversion), and here the name suggests it is a comma (however I've learned by experience not to assume anything, especially when the context is an app that doesn't work properly).
And here is an alternative way of writing the same line of code:
Dim quakeNameComma as string = linePart(1) & ","
which reads: a string variable holding the name of the quake is calculated as the second part of the line with a comma appended. Yeah, I can read that in a few milliseoonds and I know for a fact what is going on in that line. Quite a change. Now I don't need to concentrate on the line itself, I can concentrate on getting the overall picture of your code snippet; when I'm three lines down I will still remember what has happened before.
The same goes for your problem description:
This is a data line being imported
nc,71401286,0,"Thursday, May 20, 2010 01:00:54 UTC",38.8335,-122.8778,1.0,1.80,12,"Northern California"
which may, or may not, mean: the initial content of strLine is ...
and then
Message="Conversion from string "19/05/2010 02:12:54" to type 'Date' is not valid."
Are you saying the above input (May 20, 2010 01:00:54) is converted into 19/05/2010 02:12:54 and then it throws? That is a mysterious conversion, I have no clue what functionality you are trying to get; or did you just throw some non-matching examples together to make things more obscure?
So my problem overall was you were not offering much of a grip on the problem. I had to assume too many things at once to come up with a reasonable hypothesis, apart from the impression you had a date problem, probably caused by an implicit format assumption.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi Luc,
I will digest that. In the meantime, as of a minute ago and after making sure everything came out in American date format, the service is running without errors.
It has been a salutory lesson that running under Local System is a different dimension to running as a logged in user.
My most sincere thanks to you Luc as I would not have sussed this one for ages without you pointing me in the right direction. Unfortunately there is no :hail: smiley so I can't use it, but :hail: anyway.
|
|
|
|
|