[C#] First Program (SteamID Converter) menu

Shout-Out

User Tag List

Results 1 to 5 of 5
  1. #1
    Cush's Avatar Elite User
    Reputation
    504
    Join Date
    May 2006
    Posts
    528
    Thanks G/R
    3/19
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [C#] First Program (SteamID Converter)

    Hey.

    I made my first program in C# from scratch earlier, which wasnt all that difficult as I know a little of VB.net from a few years ago and understand most of the basics in programming.

    My problem is that I feel like I'm not really doing anything that is getting me anywhere aside from basic variable manipulation, and I'm not sure how to continue.

    The program is a SteamID <> Community Profile converter, as in, you can give it a SteamID and it will output a link to that person's community profile, or you can give it a community profile URL to get a person's SteamID. I'm happy with it and it works fine, but I'm insecure and always think I'm not doing things in the best way and reinforcing bad habits.

    Could anyone take a peek at my code and say if there is anything I didn't do well/Could have done better? I was also thinking of improving it by maybe having it access the profile link it creates and pull a name out if possible, any pointers on how I'd go about doing that?

    Code > C# | using System; using System.Collections.Generic; - Cush

    If anyone is interested > Download (350KB)

    Scan > [Spoiler]Antivirus results
    AhnLab-V3 - 2011.01.05.00 - 2011.01.04 - -
    AntiVir - 7.11.1.25 - 2011.01.04 - -
    Antiy-AVL - 2.0.3.7 - 2011.01.04 - -
    Avast - 4.8.1351.0 - 2011.01.04 - -
    Avast5 - 5.0.677.0 - 2011.01.04 - -
    AVG - 9.0.0.851 - 2011.01.05 - -
    BitDefender - 7.2 - 2011.01.05 - -
    CAT-QuickHeal - 11.00 - 2011.01.04 - -
    ClamAV - 0.96.4.0 - 2011.01.04 - -
    Command - 5.2.11.5 - 2011.01.04 - -
    Comodo - 7294 - 2011.01.04 - -
    DrWeb - 5.0.2.03300 - 2011.01.05 - -
    Emsisoft - 5.1.0.1 - 2011.01.04 - -
    eSafe - 7.0.17.0 - 2011.01.02 - -
    eTrust-Vet - 36.1.8081 - 2011.01.04 - -
    F-Prot - 4.6.2.117 - 2011.01.04 - -
    F-Secure - 9.0.16160.0 - 2011.01.05 - -
    Fortinet - 4.2.254.0 - 2011.01.03 - -
    GData - 21 - 2011.01.05 - -
    Ikarus - T3.1.1.90.0 - 2011.01.04 - -
    Jiangmin - 13.0.900 - 2011.01.04 - -
    K7AntiVirus - 9.75.3435 - 2011.01.04 - -
    Kaspersky - 7.0.0.125 - 2011.01.05 - -
    McAfee - 5.400.0.1158 - 2011.01.05 - -
    McAfee-GW-Edition - 2010.1C - 2011.01.04 - -
    Microsoft - 1.6402 - 2011.01.04 - -
    NOD32 - 5760 - 2011.01.04 - -
    Norman - 6.06.12 - 2011.01.03 - -
    nProtect - 2011-01-04.01 - 2011.01.04 - -
    Panda - 10.0.2.7 - 2011.01.04 - -
    PCTools - 7.0.3.5 - 2011.01.04 - -
    Prevx - 3.0 - 2011.01.05 - -
    Rising - 22.81.01.03 - 2011.01.04 - -
    Sophos - 4.60.0 - 2011.01.04 - -
    SUPERAntiSpyware - 4.40.0.1006 - 2011.01.05 - -
    Symantec - 20101.3.0.103 - 2011.01.04 - -
    TheHacker - 6.7.0.1.110 - 2011.01.03 - -
    TrendMicro - 9.120.0.1004 - 2011.01.04 - -
    TrendMicro-HouseCall - 9.120.0.1004 - 2011.01.05 - -
    VBA32 - 3.12.14.2 - 2011.01.04 - -
    VIPRE - 7956 - 2011.01.04 - -
    ViRobot - 2011.1.4.4236 - 2011.01.04 - -
    VirusBuster - 13.6.127.0 - 2011.01.04 - -
    File info:
    MD5: 0a9722444de8b51bd2f43342f8649a63
    SHA1: e98e94d3026414253f3f5cd627c88f454a54a160
    SHA256: 6ec855c55ad10e3f2f20ffa44156ba47db2e1bc88ff5089d77d2fa6d3813edc5
    File size: 356352 bytes
    Scan date: 2011-01-05 00:41:33 (UTC) [/spoiler]

    And screenshot


    [C#] First Program (SteamID Converter)
  2. #2
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1515
    Join Date
    May 2008
    Posts
    2,433
    Thanks G/R
    81/336
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Skimmed over it, all seems to look okay. You should practice String.Format() though, instead of lines like
    Code:
    textBox4.Text = "STEAM_0:" + Auth + ":" + SteamID;
    Instead, you could easily just use
    Code:
    textBox4.Text = String.Format("STEAM_0:{0}:{1}", Auth, SteamID);
    It makes it a lot easier to see what the string will look like as an end result, in case you ever want to move positions of the variables around.

    Edit: Also forgot to mention, you should practice this method to save you from having to use .ToString() in anything, it will automatically convert it for you. It doesn't apply in this case but it will come in handy in the future
    Last edited by Jadd; 01-04-2011 at 11:12 PM.

  3. #3
    Cush's Avatar Elite User
    Reputation
    504
    Join Date
    May 2006
    Posts
    528
    Thanks G/R
    3/19
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh that looks much neater, thanks

    I have just been adding bits and bobs in to it, I downloaded a custom class for storing a webpage in a variable then using regex to pull out the title, which in the case of a Steam profile is the name of the person. I used that to allow it to show the name of the person, but I also copied the class and changed it so that in the case that the profile entered is a named one instead of numbers, it searches for the real community ID in the page source and uses that.

    Im learning quite a bit from this Thanks for the input.


  4. #4
    The-Eradicator's Avatar Contributor

    Reputation
    149
    Join Date
    May 2007
    Posts
    829
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Skimmed through it, here's some constructive criticism.

    - Vouch on Jadd's point regarding String.Format.

    - Base should be declared as a constant class level variable. It won't change while your program is running, and you don't need to redeclare it each time the button is pressed.

    - Don't use catch all exception handlers. That's akin to saying "This piece of code can handle every possible problem", but that isn't the case. If there's an error unrelated to the steamid, your program would just eat it and you would never know what's wrong. If you were an end user, you would have nothing to report to the programmer, who might not be able to reproduce the problem. Instead, catch each specific exception when you know what causes it.

    - Your code isn't very robust. Instead of catching exceptions, figure out what the problem with the input string is. Catching exceptions won't give you much information about what's wrong.

    - You have an empty Form_Load event handler. I assume this is left over from something else you were doing.

    Overall, it works, but it could be done better. On the other hand, you're new, so it's a good start.


    I rewrote the steam ID --> community ID portion myself as a console program (no need to clutter the code with ambiguous form UI names) demonstrating constrained input. As I know nothing about steam IDs, I used the information here. Presumably, it's right, but I wouldn't know for sure.

    Source here.
    Last edited by The-Eradicator; 01-05-2011 at 12:51 AM.
    The most beautiful thing we can experience is the mysterious. It is the source of all true art and all science. He to whom this emotion is a stranger, who can no longer pause to wonder and stand rapt in awe, is as good as dead: his eyes are closed.
    Albert Einstein

  5. #5
    Cush's Avatar Elite User
    Reputation
    504
    Join Date
    May 2006
    Posts
    528
    Thanks G/R
    3/19
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply - I already read somewhere else that it isnt a great idea to just catch all exceptions like that, but I figured that from what I'm doing in that small bit, pretty much any scenario can be chalked down to an incorrect input when with this, both the inputs will be copied + pasted (The SteamID will be copied from the console in-game or somewhere else, and the community profile URL from the target persons profile page)

    I had the Form_Load in there because I was getting compile errors if I took it out, was a problem in the form designer code and went away when I deleted the offending line.

    Thanks for your version though, its good to see how someone with better knowhow would do it I might try to rewrite it in a better fashion tomorrow.

    +8 rep each

    *EDIT*

    I made some big changearounds with the code, and also it now has the extra class with functions for getting the name or ID of a person from their profile page.

    Form1>
    http://pastebin.com/bkXT1Xpn

    Class1>
    http://pastebin.com/ie9rxd6W
    Last edited by Cush; 01-06-2011 at 10:51 PM.

Similar Threads

  1. Rasy's first program :D
    By rasy in forum World of Warcraft Bots and Programs
    Replies: 21
    Last Post: 08-20-2009, 07:53 AM
  2. [Guide] c++ your first program will be cool!
    By Ollox in forum WoW EMU Guides & Tutorials
    Replies: 11
    Last Post: 07-12-2008, 05:49 PM
  3. My first helpful AutoIt program
    By jdismeuc in forum World of Warcraft Bots and Programs
    Replies: 21
    Last Post: 05-14-2008, 10:14 AM
  4. Replies: 2
    Last Post: 08-17-2007, 07:53 AM
  5. My first AutoIt program
    By REDACTEDSEPHI in forum Community Chat
    Replies: 3
    Last Post: 06-15-2007, 06:29 AM
All times are GMT -5. The time now is 02:35 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search