Thursday 30 August 2012

VB Program - To Create a Notepad(.txt) File and Save the data


VB Program - To Create a Notepad(.txt) File and Save the data

Steps:

1.For Creating a text file in a Vb program we use File System Object.
2.CreateObject ("scripting.filesystemobject") - This is  used to create the object of the file.
3.After creating the file object we open the file using opentextfile(location) function.
4.Once the file is opened then writeline is used to write text in the file that has been created above.
5.After writing in to the file ,the file object has to be closed using Close.

Here is a demo to create and then write something in a text file :
The below code will create the Text file(Ia2Tech.txt) and then write the data("Its all about Technology") in the file which will be saved at "D:\Ia2Tech.txt" and then will close it.

Program :
Sub Notepad()

Set objFS = CreateObject("scripting.filesystemobject")
Set txtFile= objFS.opentextfile("D:\Ia2Tech.txt", 8, True)
txtFile.writeline "Its all about Technology"
txtFile.Close

End Sub

Note : If the File is already there at a specified location then the data will be appended to the data already present in the file.

VB Program - To check if a number is Numeric or not


VB Program - To check if a number is Numeric or not

Program:
-Use of IsNumeric()

Sub checkNumeric()

Dim varNum
varNum = InputBox("Enter a Number")
If IsNumeric(varNum) = "True" Then
MsgBox varNum + " is a Numeric Value"
Else
MsgBox varNum + " is not a Numeric Value"
End If

End Sub

VB Program - To Reverse the n Digit Number entered by a user


VB Program - To Reverse the n Digit Number entered by a user

Program :

Here n= 5,this can be modified in the below code.

Sub ReverseNumber()

Dim varNum
Dim varRev
varNum = InputBox("Please Enter a number")
If Len(varNum) <> 5 Then
MsgBox varNum + " is not a 5 digit number"
Else
varRev = varRev * 10 + varNum Mod 10
varNum = varNum / 10
varNum = Left(varNum, 4)
varRev = varRev * 10 + varNum Mod 10
varNum = varNum / 10
varNum = Left(varNum, 3)
varRev = varRev * 10 + varNum Mod 10
varNum = varNum / 10
varNum = Left(varNum, 2)
varRev = varRev * 10 + varNum Mod 10
varNum = varNum / 10
varNum = Left(varNum, 1)
varRev = varRev * 10 + varNum Mod 10
MsgBox "Reverse Order of the entered number is " & varRev
End If

End Sub

VB Program - To Calculate the Simple Interest


VB Program - To Calculate the Simple Interest

Program :

Sub SimpleInterest()

Dim varPA
Dim varT
Dim varROI
Dim varSI
varPA = InputBox("Enter Principle Amount")
varT = InputBox("Enter Time(Yrs)")
varROI = InputBox("Enter Rate of Interest")
varSI = (varPA * varT * varROI) / 100
MsgBox "Simple Interest is " + CStr(varSI)
'Cstr()- Function converts the value to String

End Sub

VB Program - To find out whether the number is Even number or Odd number?


VB Program - To find out whether the  number is Even number or Odd number?

Program: 

Sub EvenOdd()

Dim varNum
varNum = InputBox("Enter a number")
If varNum Mod 2 = 0 Then
MsgBox varNum + "  is a even number"
Else
MsgBox varNum + "  is a odd number"

End If

VB Program - To find out whether the given year is a leap year or not?

VB Program - To find out whether the given year is a leap year or not?

Program : 

Sub LeapYear()

Dim varYear
varYear = InputBox("Enter the Year")
If varYear Mod 4 = 0 Then
MsgBox varYear + " is a Leap year"
Else
MsgBox varYear + " is not a Leap year"
End If


End Sub

Sunday 26 August 2012

Java Program to convert given no. of days into months and days


 Java Program to convert given no. of days into months and days.
  (Assuming each month is of 30 days)

Class DayMonth{
      public static void main(String args[]){
      int number = Integer.parseInt(args[0]);
      int days = number%30;
      int month = number/30;
      System.out.println(number+" days = "+month+" Month and "+days+" days");
   }
}

Java Program to Display Multiplication Table


Java Program to Display Multiplication Table

Class MultiTable{
      public static void main(String args[]){
      int number = Integer.parseInt(args[0]);
      System.out.println("*****MULTIPLICATION TABLE*****");
      for(int i=1;i<=number;i++){
         for(int j=1;j<=number;j++){
            System.out.print(" "+i*j+" ");
         }
         System.out.print("\n");
      }
  }
}

Samsung Galaxy Note - User Review


Samsung Galaxy Note - PhoneBlet  - User Review



Pros : 
  1. Huge Screen -5.3" 16M-color Super AMOLED capacitive touchscreen of WXGA resolution
  2. Good camera.(8MP)
  3. High screen resolution(~285ppi)
  4. Separate S Pen active stylus
  5. 2MP secondary video-call camera  
  6. Dual core 1.4 Ghz processor
  7. ICS update released and Jelly Bean to be released soon.

Cons :
  1. Not easy to use from one hand ,difficult to fit in pocket.
  2. Average Loudspeaker volume
  3. Plastic Body
  4. No separate Camera Key.

If you don't want to buy a separate tablet  then this Phoneblet is a must buy.
Its a power performance packed mini Tablet phone.

Sony Xperia S - User Review

Sony Xperia S - User Review

Pros :
Excellent camera.(12MP)
High screen resolution(~340ppi)
Dual core 1.5ghz processor
Good audio quality.
ICS update released and Jelly Bean to be released soon.


Cons :
Feels heavy.
No card slot.
No hardware issues. 1 day battery backup on average use.

Yes it is comparable to s2 ( s2 dual core 1.2ghz, xp s dual core 1.5ghz)

Thursday 23 August 2012

VB Programming Basic Concepts - If-Else-If Condition

VB Programming Basic Concepts - If-Else-If Condition

 Below are the ways to write If statements in a VB Program :

1. Simple IF

If [condition] Then
Code 
......
End If 

2. IF Else -

If [condition] Then
Code
......
Else
Code
......
End If

3. Else If -

If [condition] Then
Code
......
Else If [condition] Then
Code
......
End If