Results 1 to 14 of 14

Thread: Note transposer program may or may not need help...

  1. #1

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    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!

  2. #2
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: Note transposer program may or may not need help...

    Quote Originally Posted by timeshifter
    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!
    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. - Oscar Wilde

  3. #3

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Note transposer program may or may not need help...

    What do you mean by unrolling?

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Note transposer program may or may not need help...

    Quote Originally Posted by Maven
    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.

    % is shorthand from the old days for a INTEGER type.
    I copied this from an old thread.
    Integer %
    Long &
    Single !
    Double #
    Currency @
    String $
    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.
    Last edited by dglienna; Apr 13th, 2005 at 08:46 PM.

  5. #5
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: Note transposer program may or may not need help...

    Quote Originally Posted by dglienna
    % is shorthand from the old days for a INTEGER type.
    I copied this from an old thread.


    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.
    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. - Oscar Wilde

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Note transposer program may or may not need help...

    Quote Originally Posted by Maven
    Don't use the following syntax to declaring variables:

    Dim diff%
    Dim temp%
    ...
    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.

  7. #7
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: Note transposer program may or may not need help...

    Quote Originally Posted by RhinoBull
    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.
    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.
    Last edited by Maven; Apr 14th, 2005 at 11:49 AM.
    Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. - Oscar Wilde

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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.

  9. #9
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: Note transposer program may or may not need help...

    Quote Originally Posted by RhinoBull
    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.
    Microsoft Def:

    Coding conventions are programming guidelines that focus not on the logic of the program but on its physical structure and appearance. They make the code easier to read, understand, and maintain.
    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. - Oscar Wilde

  10. #10
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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 ...

  11. #11
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: Note transposer program may or may not need help...

    Quote Originally Posted by RhinoBull
    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 ...
    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. - Oscar Wilde

  12. #12

  13. #13
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    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)

  14. #14
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width