English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

help me to write code in Visual Basic the form comprises of a text box where numbers are to be entered, and a label box where the results are shown
1)write code to find out weather a number is odd
2)write a code to find out weather a number is even
3)write a code to show weather a group of no's is palindrome or not.

2006-07-02 04:32:26 · 4 answers · asked by Karan S 1 in Computers & Internet Programming & Design

4 answers

Okay since these are simple codes I will tell you how to do them...

To check if the number is odd or even we can say from using MATH, we can denote whenever we modulate it by two then it will be simple...

Function IsEven(intNumber as Integer) as Boolean
IsEven = False
If intNumber Mod 2 = 0 Then IsEven = True
End Function

The function above denotes if the number is even.. You could negate that to check if it is odd.

Now to check if a group of numbers is palindrome, we need to check if the reverse is equal to the normal sequence. So the challenge is just finding the reverse of that set of numbers.

In Visual basic there is a function called reverse for an array. If you place every number in an array and call the .reverse then you have a reversed set.

Sub reverseNumbers()
Dim theNumbers(2) As String
theNumbers(0) = "1"
theNumbers(1) = "2"
theNumbers(2) = "1"
Array.Reverse(theNumbers)
End Sub

That will get the reverse of those numbers. I will let you find a way to place them all together. You have to do some work!

Good Luck

2006-07-02 09:20:19 · answer #1 · answered by ? 6 · 0 0

Try this SIte :

http://www.arcatapet.net/vb.cfm

Down load some free samples go through the Code & try to understand , Now write your Own Code. The thumb rule for learning programming , only asking help for programming not the code .
Thats how i learned.

I am sorry if i sound Hard, but this is true.

2006-07-02 05:24:08 · answer #2 · answered by TheOne 1 · 0 0

If Int(x/2) = x/2 then the number is even
If Int(x/2) <> x/2 then the number is odd

2006-07-02 05:59:27 · answer #3 · answered by Dilip Rao 3 · 0 0

i cant explain or do it for you off head. if i were on my laptop with visual basic i could. but try using the "IF" statement,you know what i mean?

2006-07-02 04:37:53 · answer #4 · answered by The Prince of Laos 3 · 0 0

fedest.com, questions and answers