|
|
04-12-2005, 12:49 PM |
#1 |
|
Hyperactive Member
Join Date: Mar 04
Location: Smallville, U.S.A. StillVBNoob = True
Posts: 330
![]() |
Note transposer program may or may not need
help...
I've written a little program that just tells you what to replace
what chord with what in a song, and I'm not sure it could be made any
faster, but I just wanted to make sure before I go about updating it to a
much higher standard, so any advice on how to "Code It Better" would be
much appreciated.
Thanks! __________________ ![]() The statement below is false. The above statement is true. PM me if you know which one is true! I can't help anyone,
but please Rate my posts good anyway. |
|
|
04-13-2005, 02:27 AM |
#2 | |
|
Addicted Member
Join Date: Feb 03
Location: Greeneville, TN
Posts: 216
![]() |
Re: Note transposer program may or may not
need help...
Quote:
Don't use the following syntax to declaring variables: Dim diff% Dim temp% Instead say Dim myvar as something You're loops are tiny, you may want to try out unrolling. However I don't know how responsive visual basic will be to that optimization technique. __________________ Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. | |
|
|
04-13-2005, 03:07 PM |
#3 |
|
Hyperactive Member
Join Date: Mar 04
Location: Smallville, U.S.A. StillVBNoob = True
Posts: 330
![]() |
Re: Note transposer program may or may not
need help...
What do you mean by unrolling?
__________________ ![]() The statement below is false. The above statement is true. PM me if you know which one is true! I can't help anyone,
but please Rate my posts good anyway. |
|
|
04-13-2005, 08:41 PM |
#4 | ||
|
PowerPoster
Join Date: Jun 04
Location: Center of it all
Posts: 9,605
![]() ![]() ![]() |
Re: Note transposer program may or may not
need help...
Quote:
% is shorthand from the old days for a INTEGER type. I copied this from an old thread. Quote:
I would use a table that you could use to look up each one, so that you could just loop through each note, after knowing the amount to transpose in advance. __________________
![]() David Don't forget to add the Checkmark and the word [RESOLVED] to the subject of the first post in your thread. If your question has been answered satisfactorily, and it has been helpful, then, please, ![]() Rate this Post! Last edited by dglienna : 04-13-2005 at 08:46 PM. | ||
|
|
04-14-2005, 01:08 AM |
#5 | |
|
Addicted Member
Join Date: Feb 03
Location: Greeneville, TN
Posts: 216
![]() |
Re: Note transposer program may or may not
need help...
Quote:
I've seen it before but it's not very good pratice to use. I'm also unsure if visual basic converts that at runtime or compile time, if it does it at runtime then it's by default a varient and would effect speed. __________________ Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. | |
|
|
04-14-2005, 07:51 AM |
#6 | |
|
PowerPoster
Join Date: Mar 04
Posts: 4,101
![]() ![]() |
Re: Note transposer program may or may not
need help...
Quote:
Why the heck not - it's the same thing - just syntax that's different. Only problem with "shortcuts" is that many new programmers don't know what that symbol stands for but you may use TypeName() function to get actual datatype of any of your variables. Search through my posts and you will find a sample that demonstrates all of the above - I think I posted it few days ago. Cheers. | |
|
|
04-14-2005, 11:42 AM |
#7 | |
|
Addicted Member
Join Date: Feb 03
Location: Greeneville, TN
Posts: 216
![]() |
Re: Note transposer program may or may not
need help...
Quote:
It's a standard coding convetion to use "As Type" clause. I also remember reading something in MSDN that said if you didn't use "As Type" then the variable would be defined a varient. I'm thinking visual basic may convert this at compile time since there is some type of identification but even so, I think it's horrible coding style. __________________
Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. Last edited by Maven : 04-14-2005 at 11:49 AM. | |
|
|
04-14-2005, 04:39 PM |
#8 |
|
PowerPoster
Join Date: Mar 04
Posts: 4,101
![]() ![]() |
Re: Note transposer program may or may not
need help...
You are totally confused : declaring variable without the type specified will result in Variant type - that is true. However, declaring variable as Dim intNumber% or Dim intNumber As Integer WILL result in both case and INTEGER variable immediately. Also, if you would look closely at how windows api work then you will find in many many samples that some arguments are passed with ampersand at the end: Call SomeFunction(arg1&, arg2&) that is done on purpose to explicitly convert integer to long and therefore declaring variable as ... Dim lngNumber& is perfectly valid and normal way of declaring variables. The only problem (as I said before) not using "...As SomeType" syntax is that majority of new programmers wouldn't know what that symbol is. But there are so many things not documented, though ... And after all what is "standard coding convetion anyway ?.. Best regards. |
|
|
04-15-2005, 01:36 AM |
#9 | ||
|
Addicted Member
Join Date: Feb 03
Location: Greeneville, TN
Posts: 216
![]() |
Re: Note transposer program may or may not
need help...
Quote:
Microsoft Def: Quote:
To give you an example, I'm going to use the GOTO statement. It's something that you can use if you wanted to in visual basic. You could after all create a loop or even a if structure out of goto statements. However, it kills the idea of structured programming. I use GOTO as an example because it's probably the most extreme keyword supported by visual basic. Another reason to stay mainstream is the possibility that it will be more likely to be droped if it's outside of the standard way of doing things. If that happens then all of you're code will break if you try to port it. __________________ Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. | ||
|
|
04-15-2005, 08:32 PM |
#10 |
|
PowerPoster
Join Date: Mar 04
Posts: 4,101
![]() ![]() |
Re: Note transposer program may or may not
need help...
Let me guess: you're a student, you do programming for about 2-3
years at most but you sound like professor reading directly from one of
the academic book ... Just wonder where do you get these ideas from ??? Really silly ... ![]() |
|
|
04-16-2005, 12:19 AM |
#11 | |
|
Addicted Member
Join Date: Feb 03
Location: Greeneville, TN
Posts: 216
![]() |
Re: Note transposer program may or may not
need help...
Quote:
I think any sensible programmer would agree that it's very important to follow the standard guidelines of programming. You may not understand why these guidelines are important if you're writing very simple programs but as a program increases in size and complexity, it becomes very obvious as to why those standards exist. __________________ Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. | |
|
|
04-19-2005, 09:17 PM |
#12 |
|
PowerPoster
Join Date: Mar 04
Posts: 4,101
![]() ![]() |
Re: Note transposer program may or may not
need help...
Yea, that's what I thought. ![]() |
|
|
05-01-2005, 08:45 PM |
#13 |
|
Good Ol' Platypus
Join Date: Jan 00
Location: Ontario, Canada
Posts: 5,154
![]() |
Re: Note transposer program may or may not
need help...
I think it's standard for any sensible programmer to use a sensible
language.
Yipes. They might also stay on topic. __________________ All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. (Just a heads-up) |
|
|
05-03-2005, 11:59 PM |
#14 |
|
Hyperactive Member
Join Date: Jul 02
Location: WGTN, New Zealand
Posts: 322
![]() |
Re: Note transposer program may or may not
need help...
Apparently whenever you using string manipulation functions, such as
Left and Mid, you should always use Left$() or Mid$() because otherwise it
returns a variant and converts it back to a string. Veeery useless. |
|
|
|
| ||||||
|
|