r/visualbasic • • Dec 10 '17

Hey r/VisualBasic! I did my high school senior exit project in VB! It's a little digital assistant. Feel free to check it out!

https://drive.google.com/file/d/1P_woLkbZnrdPeQjI3jTDVWM06LkYHTcJ/view?usp=sharing
5 Upvotes

24 comments sorted by

3

u/ocdtrekkie Dec 11 '17

I'd recommend putting code on GitHub, or providing some screenshots or details. I am intrigued a little bit (because I have some assistant-ish software in VB as well), but not enough to download and unpack a RAR.

3

u/LakeAire Dec 11 '17

This is the first application I've 'published,' and I'm not familiar with GitHub. I created a GitHub account, but I'm struggling with adding the solution/repository.

I tried following this tutorial I found on StackOverflow, but got stuck on the second step 4.

Any tips? Thanks!

4

u/PFthroaway VB.Net Advanced Dec 11 '17

GitHub has its own application which is significantly easier to use to manage GitHub repositories.

Since you already started the process with Visual Studio, before this process begins, you may have to navigate to your folder with the .sln file and delete the .git folder and any file which begin with .git it may have created.

Anyway, to do this with GitHub Desktop:

  1. Download and install GitHub Desktop.

  2. Log in with your newly created GitHub account you mentioned above.

  3. Click File, then click New Repository...

  4. Give your repository a name. Usually the name of your solution is good. Since you have no other repositories yet, basically any name is good.

  5. Click Choose... and navigate to the folder your .sln file is in and select that folder.

  6. Set your git ignore to VisualStudio. Select or don't select a license. It's not required. MIT License is standard.

  7. Click Create Repository, then click Publish Repository on the far right just below the menu bar.

Simple. No weird hoops to go through like Visual Studio makes you go through.

2

u/ocdtrekkie Dec 11 '17

I would maybe add a little explanation about license too, if the OP is unfamiliar. It's ideal for people to know what rights they sign away. ;)

/u/LakeAire : If you post your source code on GitHub, anyone can view it, but technically, other people using your code is not legal at that point. In the United States, at least, you have a copyright to it simply because you wrote it. Generally you either want to allow people to use your code with conditions, so that they can do more than just look at it. The two most common are MIT and GPL-style licenses.

The MIT license is a "permissive" license. It lets people do pretty much anything they want with your code... as long as they leave your license/credit intact. They can't claim they wrote your code. But they can include your code in their own software without any major requirements.

The GPL license is a "copyleft" license, which is mostly the same in terms of people being able to use and include your software, except it requires that anyone who uses your code must also release their code that uses it with a GPL license as well. Which means people can't use your code inside a closed source product.

I personally prefer MIT, because I don't like holding conditions over sharing my code. MIT and GPL are representative of the most common licenses out there, but there are many, and they fall into various amounts of similarity to those two.

2

u/LakeAire Dec 12 '17

GitHub link. Hope it works for you (it works for me but who knows what that means)

I really appreciated the license explanation. It makes a lot of sense and I somewhat know what I'm doing now. Thank you!!

1

u/LakeAire Dec 12 '17

I've been trying to add some of my older projects to GitHub as well, but I ran across a problem. If the file name that houses my solution & project stuff has spaces, I'm unable to create a repo for it that recognizes my solution and everything.

Here on my GitHub profile I currently have two projects; my SeniorProject which seems to be functioning properly, and my TextAdventure3.0 which was originally titled "Text Adventure 3.0" but I tried changing the file name to one without spaces and it didn't seem to help.

Any help?

2

u/PFthroaway VB.Net Advanced Dec 12 '17

You can always copy in the .sln file and project folder to the newly created GitHub folder.

1

u/LakeAire Dec 13 '17

Fixed my issue! Thanks!

2

u/ocdtrekkie Dec 11 '17 edited Dec 11 '17

I've tried using Git through Visual Studio itself like... once, and it was a bit of a challenge. The advantage is that Visual Studio is aware of where you are in your repository, and you can move back and forth through it from inside VS.

I find the actual GitHub desktop app much more intuitive. You may wish to give it a try: https://desktop.github.com/

Once you fundamentally are comfortable with GitHub and how it works, it'll be much easier for you to try to contend with Visual Studio's integration with it. Eventually you will want to commit to GitHub every time you make changes, and you will end up referring back to GitHub to see what you did and when.

Some advice:

  1. Play with a folder that is NOT your only copy of your project until you know how to use source control. Make backups. Git controls what version of your software is actually in the folder, and you can undo your project if you aren't careful. In my case, I actually copy my code into my Git folder on my PC, the one I work with in Visual Studio is different. (On my tablet though, I work directly in my Git folder.)

  2. Make sure you do NOT commit any passwords or 'secrets' to your GitHub repository. This requires you use good practices like not including passwords in your source code to begin with. ;) The history of what you commit is (relatively) permanent without using some sophisticated commands, so assume everything you commit to Git is inevitably public.

This is my project as an example: https://github.com/ocdtrekkie/HAController and you can see each time I committed changes here: https://github.com/ocdtrekkie/HAController/commits/master

You may notice my SLN is not included, this is because I didn't choose the folder level my SLN was in. Which isn't too big a deal, but you'll notice what's in my repo is usually in a subfolder in most .NET-based repos.

EDIT: /u/PFthroaway pretty much has you covered with good instructions, I'm just seeing his post.

2

u/LakeAire Dec 12 '17

From your example, I assume commit means to update your work in progress on GitHub? that makes sense. When I uploaded my senior project, I had no idea what the commit button did lol.

Here's my GitHub link. Hope it works for you (it works for me but who knows what that means)

Did I do it right, do you think?

2

u/ocdtrekkie Dec 12 '17

Looks pretty good!

Yes, each time you submit changes to your code to a Git repository (GitHub is the most popular place to host Git repositories, but Git is actually open source. Anyways...), you are "committing" those changes. The cool thing is you can go back and see what you did, to multiple files, each step along the way.

And if you break something, you can undo a commit (or "revert" it), and be back to a working project. You can also work on code in separate branches and then merge them into the main project when you're ready. There's a lot you can do with it. A lot of it is meant for collaboration between multiple developers, but it's very handy for individual coders too.

If I need to know why I made a code change, I can even use the "blame" feature on GitHub to figure out which commits (by who), changed the line of code I'm looking at. If my commit description was good, I'll probably understand why I did it, even if I didn't explicitly comment the code itself.

It's always personally interesting to look at similar code. For example, your text entry handler here: https://github.com/beingDevisor/SeniorProject/blob/master/Form1.vb#L25 shares some similar code with mine here: https://github.com/ocdtrekkie/HAController/blob/master/Form1.vb#L208 though I had to move my code that handles entered commands into KeyUp instead of KeyDown.

I wondered why, and then I did Blame: https://github.com/ocdtrekkie/HAController/blame/master/Form1.vb#L208 which shows me which commits modified which lines.

As the case is, I changed mine because of a hardware LCD display I'm outputting to in my car: https://github.com/ocdtrekkie/HAController/commit/763d544a44eea8fec147bafc6fb002dc858eeccb

But then, I realized the SuppressKeyPress function only works in KeyDown, which is why I had to move that back, here: https://github.com/ocdtrekkie/HAController/commit/698eea675140bb3706113054bb88bc0188151171

Other random musings: You look for Keys.Enter and I look for Keys.Return and I have literally no idea if there's a difference between the two.

As you can see, this is pretty handy, you can link specific commits, which are essentially specific changes to your code.

2

u/LakeAire Dec 12 '17

Well dang. That's pretty neat! I do have some other questions though lol

  1. What benefit does using branches have if I plan on working on my projects solo?

  2. The GitHub desktop application is somewhat confusing. How do I go about making a new commit if I change my code?

  3. As seen on my profile here, I was able to get GitHub to recognize my Vb solution with my SeniorProject, but not with my TextAdventure3.0 project. TextAdventure3.0 was originally named 'Text Adventure 3.0' but I removed the spaces because I couldn't get GitHub to recognize my senior project until I got rid of the spaces in the file name. However, it isn't working with TextAdventure3.0. Do you know why that might be?

Thank you for all your help! You've made understanding this new system a great deal easier.

2

u/ocdtrekkie Dec 12 '17
  1. I rarely use branches in personal projects, but have if I want to save/store a commit that I know is broken and unfinished. It leaves my main branch in a working state, and I can merge the changes in the branch back to my main project later.

  2. If you make changes to the code that's in the folder associated with your GitHub repo on your computer, the Changes column will fill with a list of the files that you've changed (and you can see what the changes are when you click on each file). Then you just give it a description/summary (and a comment, if you like) and click "Commit to master". One of the buttons on the grey bar at the top should then give you an option to push the commits you've made to GitHub. After that, you should see that commit and it's changes on the GitHub website.

  3. TextAdventure doesn't have any code in it yet! GitHub marks what type of project you have based on the contents of the code files it detects in it. You'll notice if you click on the purple bar here: https://github.com/beingDevisor/SeniorProject it says your project is 100% Visual Basic. On mine, here, it says it's 99.3% Visual Basic, and 0.7% Batchfile: https://github.com/ocdtrekkie/HAController GitHub picks the most prevalent code language in your project to mark as the type of project it is.

I maybe would avoid putting periods in your project names too. Might be the problem there.

2

u/LakeAire Dec 12 '17

I messed around with stuff a little more and just found that moving my project to the created GitHub file works (for TextAdventure3). Now that I type it out, it sounds so simple lol, but I couldn't figure it out. Thanks so much! You've been a huge help.

2

u/ocdtrekkie Dec 12 '17

Glad you got it figured out! It can be kinda hard to 'see' what someone's doing over a Reddit comment. ;)

2

u/ocdtrekkie Dec 12 '17

One of the things you probably want to look at doing in the future, particularly if you end up expanding this (my assistant is for my daily use, so I regularly improve it) rather than just submitting for the grade, is decreasing code replication.

Any time you have to do something repeatedly, there is probably a better way to do it.

For instance this function (IsNumeric): https://msdn.microsoft.com/en-us/library/6cd3f6w1(v=vs.90).aspx can make lines like this: https://github.com/beingDevisor/SeniorProject/blob/master/Form1.vb#L72 or this: https://github.com/beingDevisor/SeniorProject/blob/master/Form1.vb#L81 much shorter.

L72 could be "If IsNumeric(strInput.Chars(0)) Then" for example.

The other thing you'll likely find quite exciting is Select Case: https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/select-case-statement#example which works on not just integers like the example, but string as well.

Sections like "If strSign = "-" Then" lines could be entirely replaced with Select Case strSign, and then where each case was a string for the operator like Case "+".

2

u/LakeAire Dec 12 '17

The IsNumeric looks like it'll make coding a lot easier. Thanks for the tip!

I remember learning about Select Case way back in sophomore year when I took computer programming 1, but I couldn't remember how to do it lol. Thank you so much!

2

u/ocdtrekkie Dec 12 '17

The .NET class library is insanely deep in terms of stuff it can do built-in. Sometimes I just wonder "hey, is there a .NET function to do that" and go searching around on the Internet, and find out there is. Microsoft's documentation can be a bit hard to find on it, but it's pretty good once you get in there.

2

u/LakeAire Dec 13 '17

The documentation isn't the greatest, but its contents sure are nifty!

2

u/ocdtrekkie Dec 13 '17

Any other questions you have in the future about VB, GitHub, or what I did in my project, lemme know! Your code and mine have a bit in common, so I'd be super curious if there was a new feature you came up with or the like.

And of course, my project's MIT licensed, so feel free to borrow anything that interests you out of it, or if you're curious about how or why I did something, let me know. (There's actually several really easy ways to crash mine, for what it's worth, do not take how I wrote my project to be the end-all best way to do things. ...It's not.)