Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Simply Programming C# and Visual Basic …: C# and Visual Basic
Simply Programming C# and Visual Basic …: C# and Visual Basic
Simply Programming C# and Visual Basic …: C# and Visual Basic
Ebook489 pages4 hours

Simply Programming C# and Visual Basic …: C# and Visual Basic

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Simply Programming

This is a book that teaches the basics of programming in either Microsoft's C# or Visual Basic or both if so desired. It covers all the basic functions , most variables and up to and including accessing databases from your programs.

After buying the book you can "DOWNLOAD" the example project files from; ProgrammingSimplified.Webstarts.com

The objective of the book is to build a basic knowledge of SQL database programming .... NOT to cover everything or make you an expert.

You will build a relative simple a database with three tables, various data-type of columns , enter data into the database and write "Queries" that extract , manipulate and do calculations with the stored data.

The book is available in paperback or e-book versions.

The book is available on line from XLibris Publishing Bookstore and other major publishers bookstores including Barnes and Nobles.

The downloadable files are in Winzip (Zip) format and will need to be un-zipped to use them.

I appreciate the opportunity of sharing what I have learned with you.

John Queen

LanguageEnglish
PublisherXlibris US
Release dateJun 21, 2013
ISBN9781483632810
Simply Programming C# and Visual Basic …: C# and Visual Basic
Author

John Queen

This book is for anyone interested in working with either C# or Visual Basic or both. Honestly, if you are a person with a trace of logical thinking and the desire to learn, you can do everything discussed in this book. When you’re done, you can be confident that you are able and ready to pursue and master advanced programming topics with every reason to expect complete success. The vocabulary you will need is developed in a methodical, thoughtful process by relating techniques to results. It is not a memorization exercise. My personal preference is C#, probably because I started working with “C” at AT&T Computer Systems when “C” was in its infancy. For a beginner, VB is a little less demanding and accomplishes the same job, just a little differently in terms of syntax and a few key words. Remember the old saying “Monkey see, Monkey do”? It should say “Monkey see, Monkey do, Monkey learn”!!! The text is very focused …Almost every sentence is an instruction to do something … or explains very pointedly the expected results of what you are going to do. In most “Teach Yourself books” you read many, many pages and get (forget) concepts confused before you put them to work. Forgetting or being confused by waiting will not be your experience this time. Concepts are presented in bite-sized units that make immediate use of the ideas. The focus is “doing”. I’ll say it several times before we’re done… If you’re not making any mistakes, you’re not trying hard enough!! Experiment and learn. I progresses rapidly through the fundaments of developing and testing applications that work, with minimal discussion of issues of little or no immediate use. The vocabulary is kept to every possible extent, to plain English. The examples are written with the idea that they will be used as reference and “copy and paste” code for other application the reader will develop on their own, later. Neither time nor effort is wasted filtering through text that accomplishes nothing. All text is related to the task at hand. Even in database tutorial, where some serious explaining is done before coding. The coding is kept to simple, straight-forward, step by step processing. Commands are not nested inside other commands which makes them in-decipherable to most people getting started in the field and gives me reason to hesitate when I see the extreme forms of this style of coding. Code for both C# and VB are provided for “every” exercise. The downloadable code examples are available from the publisher’s website and they work!!!

Related to Simply Programming C# and Visual Basic …

Related ebooks

Programming For You

View More

Related articles

Reviews for Simply Programming C# and Visual Basic …

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Simply Programming C# and Visual Basic … - John Queen

    Simply Programming

    C# and Visual Basic…

    John Queen

    Copyright © 2013 by John Queen.

    All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without permission in writing from the copyright owner.

    This book was printed in the United States of America.

    Rev. date: 06/13/2013

    To order additional copies of this book, contact:

    Xlibris Corporation

    1-888-795-4274

    www.Xlibris.com

    Orders@Xlibris.com

    132311

    Contents

    About the Author…

    Introduction to C# and VB, Simply Programming…

    Project 1 Forms, Button and Messageboxes

    Project 2 Controls and Handling events

    Project 3 TextBox Controls/Objects, User Input and Variables

    Project 4 Locating sub-strings within a string

    Project 5 Options, Comfort and Convenience for use of the text editor.

    Project 6 Buttons, TextBoxes and Arithmetic

    Project 7 Using Radio Buttons and Group Boxes

    Project 8 Looping, Making decisions and exiting

    Project 9 Next up… While Loops and Decision Making

    Project 10 Next up… DO Loops

    Project 11 Switch Case Decision Making and ListBoxes

    Project 12 Methods and Functions & arithmetic… creating, calling and passing parameters

    Project 13 Next up… .Functions DoSubtraction

    Project 14 File Operations; Reading, Writing, Appending.

    Project 15 Advanced Controls… Calendar and DateTimePicker

    Project 16 Next Up; Using multiple forms

    Project 17 Class properties… Set and Get properties

    Project 18 Next Up… Structs (for Structures)

    Project 19 Next Up Collections (In this case form control collections)

    Project 20… Accessing and Manipulating databases

    Project 21 Single dimension array

    Project 22 Two-dimension arrays:

    Appendix A… VB Code for Forms TextBoxes Variables RadioButtons

    Appendix B… VB for loop

    Appendix C… VB ToDo, comboBox, file reader project.

    Appendix D… C# comboBox, File IO, for ToDo items.

    Appendix E… btnThisMonth

    Appendix F

    Appendix G Hiding listBoxes and clearing textboxes

    Appendix H… VB code for ToDO dateTimePicker exercise

    Appendix I… VB Forms and properties

    Appendix J VS VB Simple Class Proj

    Appendix K VS CS Simple Class Proj

    Appendix L… CS Code for Arrays

    Appendix M… C# Struct

    Appendix N

    Appendix O VB Code VS VB Structs with File IO

    Appendix P

    Appendix Q

    Appendix R MessageBox Results… Confirm Delete

    About the Author…

    I am not the usual technocrat. I am a technician more than a philosophy or theory person. I make things happen, I travel the shortest route possible from idea to results.

    My objective is to help the "willing become the able", NOT doing the job for them.

    Or, put another way by better writers;

    2 Timothy 2:15 King James Version

    Study to shew thyself approved unto God, a workman that needeth not to be ashamed, rightly dividing the word of truth.

    1 Thessalonians 4:11 King James Version

    And that ye study to be quiet, and to do your own business, and to work with your own hands, as we commanded you;

    I realize there are those who are not pro religion (Christian to be more specific) and might be against such thinking… those people are important to me as well, but I cannot be swayed from my own beliefs to accommodate theirs. I am instead concerned that I motivate and enable everyone that will make the effort to become informed and self sufficient… The rest… . I leave in the hands of their almighty, by whatever name they choose and as their beliefs dictate.

    My proudest achievement is my family of five children who are busy becoming successful, responsible persons, probably due to their mother’s ability more than mine.

    My academic exprience is engineering, chemistry, mathematics and psychology. I attended the University of Kentucky,Washburn University of Topeka, Kansas and Cumberland College of Williamsburg, Kentucky.

    My work world experience includes installing TV antennae in the days when you needed them… repairing radios and televisions, playing guitar in a 60’s rock band, working in a hospital as an emergency room orderly, piloting military fighters, electrician for Goodyear Tire & Rubber co., engineering switching offices for the AT&T system, programming IBM mainframes, database programming (the 6th largest and busiest one in the USA), IT Team Leader for a major Healthcare IT system, instructing and managing a major corporate training center and operating a software development company of my own. I also designed and built a house of my own from the foundation up, nail by nail, board by board, wire by wire and pipe by pipe and rebuilt several cars and engines for my kids as needed…I even taught them a few mechanic skills.

    I RESPECT and EXPECT real EFFORT with real RESULTS.

    If it doesn’t work… FIX IT!! If it works… make it better.

    Once it’s working right… SHARE IT!!

    Enjoy the book… use it as a reference and make any suggestions you have to make it better. All references to C# and Visual Basic refer to the trade marked and copy righted Microsof products. I acknowledge and respect theirs rights.

    If you like it, tell others, don’t like it tell me, but tell me why. I continue learning too and so will you!!

    John Queen… Erwin, Tennessee

    jxqueendad2@gmail.com

    Introduction to C# and VB, Simply Programming…

    This book is for anyone interested in working with either C# or Visual Basic or both. Honestly, if you are a person with a trace of logical thinking and the desire to learn, you can do everything discussed in this book. When you’re done, you can be confident that you are able and ready to pursue and master advanced programming topics with every reason to expect complete success.

    The vocabulary you will need is developed in a methodical, thoughtful process by relating techniques to results. It is not a memorization exercise. My personal preference is C#, probably because I started working with C at AT&T Computer Systems when C was in it’s infancy. For a beginner, VB is a little less demanding and accomplishes the same job, just a little differently in terms of syntax and a few key words.

    Remember the old saying Monkey see, Monkey do? It should say Monkey see, Monkey do, Monkey learn!!!

    The text is very focused…Almost every sentence is an instruction to do something… or explains very pointedly the expected results of what you are going to do. In most Teach Yourself books you read many, many pages and get (forget) concepts confused before you put them to work. Forgetting or being confused by waiting will not be your experience this time. Concepts are presented in bite-sized units that make immediate use of the ideas. The focus is doing.

    I’ll say it several times before we’re done… If you’re not making any mistakes, you’re not trying hard enough!! Experiment and learn.

    I progresses rapidly through the fundaments of developing and testing applications that work, with minimal discussion of issues of little or no immediate use. The vocabulary is kept to every possible extent, to plain English.

    The examples are written with the idea that they will be used as reference and copy and paste code for other application the reader will develop on their own, later. Neither time nor effort is wasted filtering through text that accomplishes nothing. All text is related to the task at hand. Even in database tutorial, where some serious explaining is done before coding.

    The coding is kept to simple, straight-forward, step by step processing. Commands are not nested inside other commands which makes them in-decipherable to most people getting started in the field and gives me reason to hesitate when I see the extreme forms of this style of coding. Code for both C# and VB are provided for "every" exercise. The downloadable code examples are available from the publishers website and they work!!!

    I advise against trying to copy and paste code from the book’s text… word processors can and do mangle code for formatting and cosmetic reasons that the program compilers don’t quite understand.

    Download and work from the example files. The text is for studying, the code included there is for understanding, not executing.

    The topics cover the gamut from simple forms and controls to accessing databases and making updates or additions to the database tables using SQL Server 2012 express.

    When I show you a line of code, it is used with the controls (and their events) we just added to the form. This is how applications work and you won’t have to wait to see the results in some future discussion.

    When I add a control to an exercise, I add the relative code immediately. Code is useless without controls and controls are useless without the code.

    The book’s organization is built around units of code and controls that work together to do something useful, not individual items that stand alone in a theoretical discussion.

    There are several units listed in the table of contents. As you read through the units you will see that each line is numbered.

    When you go between the text and the Microsoft Visual Studio editor to implement an instruction you won’t waste time looking for the location of your instruction in the text when needed. You can return to the exact spot you were reading from before with no lost time or distraction.

    This might sound somewhat trivial… it is not trivial, instructions without line numbers are a major source of frustration when you are trying to concentrate. You forget where the instructions were located and waste time and energy searching for them.

    At regular intervals you are asked to stretch your efforts somewhat. This is a major boost to the learning process. For example, I’ll provide code for C# and ask you to convert the code to Visual basic or vice-versa. Don’t worry, I’ll put the answer out of immediate view in an appendix until you have made your best effort on your own.

    Again, I cannot, and do not try, to teach you everything there is to know. I do equip you to learn advanced concepts on your own. I did that on my own and so can you!!!!

    With the knowledge you gain from this book you can create quite sophisticated applications. You are limited only by your own imagination and effort. Go for it!!! I knw, it’s too soon to be repeating myself but, No mistakes equals not… etc, ect.

    C# and Visual Basic… Simply programming

    C# and Visual Basic… Simply Programming

    (Copy rights reserved for John Queen, Erwin Tennessee as of Jan 20 2013)

    A word of caution . . . this subject can eat you alive. You can be hooked and spend days on-end sitting in front of your computer.

    I advise against that very strongly for reasons of Health and Happiness!!

    You need an escape. I play guitar, watch sports, mess around with our horses and "ALWAYS" make sure I am paying attention to my wife and family.

    Those are the reasons for living, this is just a means of earning my living, welllll mostly. The truth is you can get a real ego trip from making a computer do what you want, the way you want, when you want. Enjoy what you’re doing… don’t be enslaved by it. Beware!!!

    OK, having said that, this is a What to do, do this book… Not a Why to do or Philosophy of doing or History of development book. All of that gets in the way when you are first starting.

    In this phase of programming, history of the evolution of the technology doesn’t have many benefits that you can use. Later, if you’re still interested that’s a different story.

    Experts are a dime a dozen and, many times, worth just about that much. I am not trying to impress you with what I know, but what I can share with you. Hopefully, you can use the knowledge to improve your life and enjoy it more. Computers and computing are going to be with us a long, long time in one form or another.

    What qualifies me to write a book? Lots of study, programming experience and raising five kids.

    With that qualification set I think I can do just about anything. Also a degree or two unrelated to programming (well, unrelated as I see it… math, chemistry, engineering, psychology).

    I started programming in 1971 with an IBM System 36 Mainframe, well, e thought it was back then, and something called RPG… as a matter of survival.

    My database experience goes back a long, long way also… around 1972. I started with something called Informix and have worked with many more since then including IBM’s DBase, SQL and Oracle. I’ve also worked quite a lot in the UNIX operating environment.

    I’m on Facebook.com as John Queen, Erwin Tennessee if you want to know more.

    The example code works correctly in the environment I describe in the list of development tools… . No ifs, ands or buts. I developed then tested every single example multiple times. Outside that environment, I make no claims about whether they work or not. I wrote more than 600 of them then chose the ones that best meet the teaching/learning requirements, as I see them.

    I Do NOT RECOMMEND COPYING and PASTING Code from this textbook straight into your MVS editor (Microsoft Visual Studio Editor—see the tools list).

    Word processors do things to the text that your MVS editor/compiler does not tolerate well for the purpose of making the document more readable and cosmetically appealing.

    Download the example code from the website of the publisher and use those files directly or copy and paste that code into MVS. The code (text) in the book is for studying, not for compiling and executing.

    There are scads of books with code that doesn’t work… at least as advertised and written. Many times when the code works, the explanations are wrong and that’s probably just as bad or worse.

    There are also some very good ones with code that does work and good,complete, understandable explanations. The problem is that you don’t know which is which until you try them. Testimonials are bountiful but not very reliable as a general rule. Members of the technical community don’t want to offend others and there are many benefits of having strong support in this career field and most others as well.

    I suggest that you keep an un-modified copy and a working copy of the files.

    One thing at a time… don’t skip around. Each task builds on the previous ones. My code is simple, bare-boned code. There are many ways to enhance it with things like error trapping and other functions. That’s not where we are right now.

    Here’s what you can expect . . . nothing more, nothing less;

    Instructions you can understand, in plain English.

    Examples that work, make a point and build on each other.

    Windows forms applications… . Not ** console applications.

    Getting user input and using it to accomplish a job…

    Returning the desired results to the user when the job is done.

    Variable usage like strings, integers etc.

    Commonly used controls, textboxes, buttons, labels etc… nothing exotic.

    Control processes like looping, counting, ending.

    File operations…reading, creating, appending deleting etc…

    Basic Database applications… reading, updating, deleting.

    E-Mail consultation as possible given volume and time constraints.

    ** NOTE: (Remember Microsoft DOS, Circa 1980, and the Command line prompt (C:\>) where you typed in your commands… that’s a console application)

    When we’re done you will have a firm grasp of the fundamentals. You will be able to write your own programs that work and accomplish meaningful tasks and results. You won’t know all there is to know about programming or C# or Visual Basic. You never will. I won’t either.

    My objective is to equip you with enough knowledge to go on and learn as much advanced programming as you want after getting the fundamentals down. I learned on my own… with a little help from time to time. So can you!!!!

    The art of programming is pretty straight-forward, but deceptively demanding.

    Take a task and break it down to the most minute level of detail possible then make one small step at a time. Check your work, revise it until you are satisfied and it works correctly, every time. That’s programming.

    Pick a time when you can concentrate on this project and try to limit yourself to no more than 2 hours per session. Don’t do this when you are sleepy, very tired, angry or otherwise distracted.

    It’s ok to stop mid-way through a project and come back later. Your sub- conscious mind will solve many issues for you when you are away from the keyboard. Give it a chance.

    Caution . . . A big aid to programming is the Cut & Paste capability. Be aware that not everything cuts and pastes characters exactly as the same character your Microsoft Visual Studio editor compiler expects… .

    Examples that I know of include the single quotation mark and the normal, double quotation mark. Word processors have the apostrophe . . . that is not the same as the single quotation mark necessarily as well as the difference of the double quotation marks that are paired together.

    Copying code from a book is a great time-saver but it can also introduce errors at times.

    Another example is where the Word processor spreads (wraps) text over more than one visible line. The Microsoft Visual Studio (MVS) editor expects a special Line Continuation character when code is spread over more than one line. These differences and others can cause compiler errors!!!

    In other words the program won’t work.

    Copy and Paste from the example code files.

    Now, you’ll need some tools to work with. This is the list;

    The SQL tools can wait if you so desire. We won’t need them just yet. But when we get to the Database examples, you’ll need them.

    You need these development tools for this work, some are free from Microsoft@;

    Relatively modern PC or Laptop.(Mine is an HP/Compaq Presario 2010 model)

    Any PC that uses the Windows XP operating system or later is fine.

    Enough hard drive and RAM capacity to satisfy your performance expectations.

    (I have a 500 gByte hard drive and 4 gByte of RAM)

    Microsoft Windows Operating system… XP or Windows 7 or 8 (I use 7)

    Microsoft Visual Studio (I am using MS Visual Studio 2010)

    Microsoft SQL Server (I use SQL Server 2012 Express… free)

    Microsoft SQL Visual Management Studio (I use SQL 2012 Express… free)

    Microsoft’s Northwind example database (free from Microsoft)

    Knowledge of Notepad . . . It is a Windows accessory. It creates clean, un-formatted text files. I use those as Target Files for applications as we go along.

    Instructions for installing these are available directly from Microsoft.com.

    AS I said…experts are a dime a dozen (just ask one) and many times worth just about that much. I am not trying to impress you with what I know, but what I can share with you.

    My expectation of you is that you want to learn, are willing to do the work necessary to learn and able to accept that errors are part of learning . . . not the Black Plague. I make plenty of them and if you don’t, you’re not trying hard enough.

    Right now you should know about the basics of using a computer, how to get around in Windows, create or modify folders . . . a little word processing is good for right now and some Spread Sheet experience might help when we get into the database portion of the book. I also think that High School Algebra is an advantage . . . but not a necessity. Mathematical talent and training are great but not an absolute requirement for programming. Common sense and persistence with attention to detail ARE.

    Don’t rush out and buy a lot of books just yet.

    I suggest that you save your money until you see just how interested in programming you really are. Follow my instructions, be persistent and, for Gosh sakes, make some mistakes!! When things go wrong… Exhaust every effort possible before you ask for help . . . that is where a lot of the real learning takes place. But, at the same time, don’t suffer too long . . . If you have tried your best and it’s still a problem, ask for help. Most mistakes are quite simple and easy to resolve. Typos are the biggie!!

    Experiment… I cannot and do not try to cover every possible detail of using things like all properties of the control objects we will be using in this book. Experiment with these things!!! Learn by trying and doing!!!

    OK, if you have the tools installed… let’s get going.

    Create three(3) new FOLDERS on your hard drive.

    Something like… VS VB Projects and VS CS (for C#) Projects. Two project folders for the programs you will create. I used JQ VS VB Projs and JQ VS CS Projs. The third is for Target files for your programs… I called mine App Target Files. We will put things like test files there later as we develop more complex programs/applications.

    One folder is for C# projects, the other for the VB projects. Be organized, it pays high dividends.

    Why? Because later you will find yourself hard pressed to locate examples of various things that you want for reference. Organization is a major part of success in that regard. Cut and paste is a large staple of programming. You will do a lot of this. Make it easy on yourself. As you progress you may want to create sub-folders in each category i.e. Database, etc.. That’s up to you.

    I suggest that you start with Visual Basic. I’ll show you exactly how in a moment.

    VB is more forgiving than C# . . . but attention to detail is the key for both. If you want to do both, that is fine. Both languages are 80% of the same stuff… with some differences in syntax and a few Key Words.

    If you choose C#, that’s fine too. I have included examples for each language.

    Got your tools installed, ready to use and your new folders created? Then we are on to the next step. Let’s do something and learn a little.

    Project 1

    Forms, Button and Messageboxes

    We are going to do a pretty simple project to get started by creating a new project, adding a button and a messagebox into the mix to see how all this works together. The screen produced by the program (code) will look like this;

    Image50223.JPG

    Screen 1a

    Project 1… . Creating

    Enjoying the preview?
    Page 1 of 1