Showing posts with label Visual Basic. Show all posts
Showing posts with label Visual Basic. Show all posts

Thursday, March 3, 2011

Learning and Applying

Its been forever until my last post, but I just didn't have time to give some thoughts to write. I have been busy in school and college, but I still have so many ideas to write. I am still on my promise to write the last basic post for Visual Basic and then I may dig deeper into more learning. I am trying to find a good book for people in my age and beginners about programming or software engineering in general, just for the sake of knowledge. I know there are many references in the internet, but I like to have the book with me all the time rather than going to the website and read.

This quick post is only about few pictures I enhanced few days ago in Camera Raw and Photoshop. I just felt I didn't posted my photographs since months, and I needed to do that. I have more pictures to share but I need to fix them first. Here are few images I like to share:

I love the drops on the flower. I sharpened them and used different blending modes to have this result. I used macro lens and without a tripod! I got this image by my luck laying down on the ground in a rainy day.

This is heavy processed. I took it to Camera Raw and played with the temperature, then into Photoshop with using different blending modes and blur too.

My sister look like an old lady after editing with wrinkles under eyes ( sorry sofie! )
The pupil had the most attention in this picture. I kept using different sharping to get a little bit of reflection. I am still not very satisfied with it, but I just chose to share it.

I learned this trick of Black and White from The Mac Lab Video Tip of the Day from my Digital Arts class. I liked it and it is so easy... it gave a whole lot meaning to the picture.

Thats all I wanted to say for now. Hopefully this weekend I have another update for programming or photography.

Wednesday, August 18, 2010

Programming- Lesson #5 ~ The For...Next Loop

"Good code is short, simple and symmetrical -the challenge is figuring out how to get there" - Sean Parent

Good programmers will choose the best path to complete a program. It's a good practice if you write concise or minimal code to achieve. This can be achieved by mastering the language features and learn by experience what the most efficient approach to achieve results is. But the problem is here; sometimes we can't know how to make it easy and simple to get the results we want, so we take the hard path and get to complicated steps. By experience and skill, it will be easy to figure out how write codes in a simple, short and symmetrical way.

The previous lesson is how to repeat or lets say " loop " the code block for many times. What if we want to repeat this block code only 2 times or for a certain number? Let's modify the Main method and greet 4 people only ( which means , the loop will be repeated 4 times only ). Look at the image below:

Let's link to the previous lessons and see how this example worked.

The counter variable i to the start value which is 1. VB will test it and see that it is less or equal than th end value, which is 4 here. If the start value is less than or equal the end value then the loop will work and the block code will be executed. When you press Enter ( after running the program ); VB will add 1 to the counter variable i and this way the For Loop will continue working and printing the certain number of statements on the screen. And the program will do the same steps again, see the block code if it is equal than or greater than and print the next statement and so for and so on.

The counter variable (i) is the tool that makes the loop repeat for certain number of times. If it is 1 time then it do it's own work, if it was 2 then it will do it's work also. Here is a table of the value variable (i) for the For Statement to check if it will loop again or not.

You can use any numbers you want for the start and end value. That was just an example of how many times you want the statement to stay looped or repeated.

School will start soon and I'm willing to write two more lessons and then I will try to keep giving lessons of the things I'm reading although I know I will be busy in my senior year and won't have that much time like now. The next lesson will be about classes and how to create your own.

Friday, July 30, 2010

Programming- Lesson #1 ~ Creating Your First Program

"The function of good software is to make the complex appear to be simple" - Grady Booch

It is interesting how everything appear to us in the screen simpler than what it really is. Look now at the header of my blog, this has a long code. Look at the title of the blog, it has a code to be appeared this way. Everything on the computer, windows, and internet is edited by Computer Language, written as codes, tested and then appear to us in this way. We can use it easily by just clicking the link. I am sure almost anyone who use the computer knows this. But I like to share what I am learning now; how to program. It is not a very hard thing once you understand it; it is just like a chain. Things are linked and connected to each others...if you didn't understand the first step then you should not move on. I did not program anything yet, I am still learning and sharing my readings with you.

I first started reading about
Visual Basic Programming Language, because this language uses symantics that somehow more readable language than other programming languages which make it easier to grab and apply. So obviously, I will understand everything from the roots in a fun, easy way. You can download it from here to your computer so you can start programming. It's free! let's get started.

Open a new project to start with, but before that you need to make sure that the button "Start without Debugging" is one of the options of "Debug" in the tool bar.

This is a screenshot of the bar itself:




" Debug" is the process that trace the bugs (errors) and fix them so you use the debugger to fix them or find where they are. For example, if you have a minor mistake in the code, this debugger will fix it and tell you why the program didn't run as you expected. If you " Start Without Debugging " then the compiler will start the program without enabling the debugger to trace the errors. The next step is creating the simple program which beginner programmers always call it "Hello World!"... I found it funny, because it is really a new world (programming) to say "Hi" to.


As you insert the "Hello , world!" code between the
Sub Main , you can run the program by clicking " Start Without Debugging" in the tool bar. It is the button we added previously. And as you can see, whenever a code end or starts there should be an End Sub or Sub Main (starting the code). The "Sub" is actually a “subroutine" which what do the actual work in the program, everything in between is part of the subroutine.

Are you wondering what contains the subroutine? Well, there are two statements, they called "
Module" or "Class"…and what they do is having all the information and codes under them. And of course, there is "End Module" that ends the code. Yes, I told you everything is like a chain; everything is part of something and contains different information.


Now, you need to define the variable ( where it stores the data on the computer's memory like text, numbers, integer..etc) and specify the type of it. For example, I want to store this text value " Hello, world!". So what I do is define this variable and name it whatever I like, I would name it " World " or " Message " or any subject you want; in order to save this text in the variable, I will define it as String so I can store them on the computer. " String " is a type to define a variable, and there are many other types we will learn later on.


"Console.WriteLine" is a function in this VB Program that print the codes on the screen while running the program. So when you write Console.WriteLine(" Hello, world!") it will print " Hello , world! "on the screen. It basically print the value of the variable.


Those are the types of Variables:
1) Integer - values between -2,147,483,648 and 2,147,483,647.
2) Byte - values from 0 to 225.
3) Decimal - values with decimal places between ±1.0×10-28 and ±7.9×1028.
4) String - sequence of character.
5) Char - value of one character.
6) Boolean - logical value, True or False.

Let me give another example of different variable type.
I want to calculate the sum of 1 and 3 . Logically, they are integer, so I will use variable of type Integer. So I will write " Dim Total as Integer " - this tells the computer to define the variable as Integer type. Then I would use it as " Total = 4 ". The computer will finally calculate it and save the results as a Total variable.

And by the way, you can't use as a "Integer" value when you put quotes ("") around your variable. VB Program will receive it as a "String".

Now as you put the codes in the right places and define the variables correctly, this what you should see before running the program:



Press any key to dismiss the window.


That was our first lesson..I hope I will get to more complex programs after a while. My next lesson will be about how to use mixed Variables and deal with errors in your program.