VB Beginner - Questions

  • Thread starter Thread starter Euvin
  • Start date Start date
E

Euvin

Const Pi as Double

Would you consider Double to be a Variable? And what does Double mean?
What is its purpose?
 
Euvin said:
Const Pi as Double

Would you consider Double to be a Variable? And what does Double mean?
What is its purpose?

'As <type>' specifies the type of the variable/constant. A
variable/constant of a certain type can only contain a value of this type.
In the example above 'Double' is a type, not a variable.
 
Const Pi as Double

Would you consider Double to be a Variable? And what does Double mean?
What is its purpose?

Double is a type and "Pi" is variable in your sample whose value is
usually accepted as "3.14". Purpose of declaring "Pi" As Double based-
on getting pi number with decimal / floating point part. If you
declare it as integer, you won't get any decimals,only you can get 3.
That's the point of double.

Regards,

Onur Güzel
 
I am having problems posting questions here. i have posted the same
question several times. it says that my posting was succesful, but i
do not see it.
anyone care to tell me what is going on
 
Dim FirstNum, SecondNum As String double

I would like to an addition type to this statement, such as <double>
How would I write that? I tried to add a comma, but that didnt work.
 
Posts don't necessarially appear immediately after you make them. It can
take a while for the news server to update.
 
An operator is a symbol that tells the compiler what kind of operation you
wish to perform. Operators vary from language to language, but in VB some
of the more common ones are:

+ (mathmatical addition)
- (mathmatical subtraction)
/ (mathmatical division)
* (mathmatical multiplication)
& (String concatenation)
= (assignment or equality test)
< (less than)
(greater than) <= (less than or equal to)
= (greater than or equal to)
<> (not equal to)

With all due respect, this and your other question are very elementary
questions, and there is nothing wrong with that (you've got to learn this
stuff sometime), but you might find it extremely helpful if you pick up an
introductory book on programming concepts as well as try a Google search on
terms like variable and operator before posting. You may find that you can
get your answer faster that way.

Of course, if you get stuck, feel free to post.

-Scott
 
You can't declare variables of different types on one line together. You'll
need a new line for that:

Dim a, b As String
Dim c As Double

-Scott
 
Hello Euvin,

An operators are (same as in math) +, -, *, /, =.
There are some additional operators you might need which are "And",
"Or", "AndAlso", "OrElse" and "&".

Example (math):

Dim Variable As Integer 'Here the value is automatically assigned to 0.
Variable = 1 + 2

"Variable" will contain the value 3.


Example "And":
Dim Variable1 As Boolean = True
Dim Variable2 As Boolean = False
Dim Result As Boolean

Result = Variable1 And Variable2

"Result" will be False. It can only be True if both Variable1 AND
Variable2 are True.

The truth table is like this:
Variable1 Variable2 Result
False False False
True False False
False True False
True True True


Example "Or":
Dim Variable1 As Boolean = True
Dim Variable2 As Boolean = False
Dim Result As Boolean

Result = Variable1 Or Variable2

"Result" will be True, if either Variable1 OR Variable2 is True.

The truth table is like this:
Variable1 Variable2 Result
False False False
True False True
False True True
True True True

"AndAlso" and "OrElse" are also "And" and "Or" operators, but with a
difference:

AndAlso will only check the next value if the first one matched the
criterion. If it does not, the next values will not be evaluated.

Dim Value1 As Integer = 1
Dim Value2 As Integer = 2
If Value1 = 1 AndAlso Value2 = 2 Then
MsgBox ("Match")
'Will be shown.
End If

Dim Value3 As Integer = 3
If Value2 = 3 AndAlso Value3 = 3 Then
MsgBox ("Match")
'Will not be shown
End If

You could replace the AndAlso operator with this:
If Value2 = 3 Then
If Value3 = 3 Then
MsgBox("Match")
End If
End If

OrElse does exactly the opposite: If a value does not match, it will
check the next value.

Dim Value1 As Integer = 1
Dim Value2 As Integer = 2

If Value1 =3 OrElse Value2 = 2 Then
MsgBox("Match")
'Will be shown
End If

Best regards,

Martin

Am 13.04.2008 07:17, schrieb Euvin:
 
Back
Top