| | |
Variable declaration!!!
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 27
Reputation:
Solved Threads: 0
I have a class named Account so I have a question. In the declarations of a new instance
Dim Newaccount as Account -----but I can declare this like..
Dim Newaccount As Account = New Account
which are the differences between both declarations?? are the same or not?
excuse me english...
besides I have another question
I have 3 functions in mi clasee
writename()
writeaccount()
writesave()
the first 2 functinos are string..so i have this.
IF name = "" then
Console.writeline("name is empty")
is the same with account and save
but the problem with save is DOUBLE so if is ="" ..I have this error.....saying....Conversion string "" in TYPE DOUBLE is invalid.............
what I can do??? because I want textmessage saying "save is empty" IF is empty
Dim Newaccount as Account -----but I can declare this like..
Dim Newaccount As Account = New Account
which are the differences between both declarations?? are the same or not?
excuse me english...
besides I have another question
I have 3 functions in mi clasee
writename()
writeaccount()
writesave()
the first 2 functinos are string..so i have this.
IF name = "" then
Console.writeline("name is empty")
is the same with account and save
but the problem with save is DOUBLE so if is ="" ..I have this error.....saying....Conversion string "" in TYPE DOUBLE is invalid.............
what I can do??? because I want textmessage saying "save is empty" IF is empty
Last edited by gouki2005; Aug 13th, 2008 at 4:37 am.
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
The first just declares a variable as the class. The second creates an instance of it.
Without seeing your code I would say you need to put in "Exit Sub" after your If statement.
If it is a subroutine:
If it is a function:
Without seeing your code I would say you need to put in "Exit Sub" after your If statement.
If it is a subroutine:
VB.NET Syntax (Toggle Plain Text)
IF name = "" then Console.writeline("name is empty") : Exit Sub
VB.NET Syntax (Toggle Plain Text)
IF name = "" then Console.writeline("name is empty") : Return Nothing
Last edited by waynespangler; Aug 13th, 2008 at 5:50 am.
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
•
•
Join Date: Jun 2008
Posts: 27
Reputation:
Solved Threads: 0
Sorry..the 3 are not function the 3 are SUb.....so how can I fix the error with double type..string is not a problem....but when is double...a exception..appears..
beside the diffrences between
use a instance of the class with using a variable.to use the class...like my first post
beside the diffrences between
use a instance of the class with using a variable.to use the class...like my first post
Last edited by gouki2005; Aug 13th, 2008 at 1:42 pm.
hi,
First one is just a Reference not Referring any object. With out referring any object using reference (Like first one) is an exception (NullPointerException)
Second one is a reference and referring an Account object.
And then
Are you mean how to check when double valued field is left out? I think so
when no value given to double (that is default value ) is 0.0
So
•
•
•
•
Dim Newaccount as Account -----but I can declare this like..
Dim Newaccount As Account = New Account
Second one is a reference and referring an Account object.
And then
Are you mean how to check when double valued field is left out? I think so
when no value given to double (that is default value ) is 0.0
So
VB.NET Syntax (Toggle Plain Text)
Dim Save As Double ..... If Save = 0.0 Then MessageBox.Show ("Empty Double") End If
KSG
•
•
Join Date: Jun 2008
Posts: 27
Reputation:
Solved Threads: 0
•
•
•
•
hi,
First one is just a Reference not Referring any object. With out referring any object using reference (Like first one) is an exception (NullPointerException)
Second one is a reference and referring an Account object.
And then
Are you mean how to check when double valued field is left out? I think so
when no value given to double (that is default value ) is 0.0
So
VB.NET Syntax (Toggle Plain Text)
Dim Save As Double ..... If Save = 0.0 Then MessageBox.Show ("Empty Double") End If
Public Sub save(ByVal sav As Double)
If sav= 0.0 Then
Console.WriteLine("Is not valid")
Else
mainsave = sav
End If
•
•
•
•
VB.NET Syntax (Toggle Plain Text)
Public Sub save(ByVal sav As Double) If sav= 0.0 Then Console.WriteLine("Is not valid") Else mainsave = sav End If
VB.NET Syntax (Toggle Plain Text)
Dim save As Double If TextBox1.Text = "" Then ' check if the textbox is empty save = 0.0 MessageBox.Show("Empty Double") Else save = Convert.ToDouble(TextBox1.Text) 'if it is not empty convert the string to double and store it in save variable End If
I hope that help you
•
•
•
•
i need sample project using vb.net if u know anything please send me
Last edited by manal; Aug 14th, 2008 at 11:24 am.
"give only what u willing to receive "
![]() |
Similar Threads
- const reference variable declaration more efficient ? (C++)
- Help with variable declared inside an if block (C++)
- Regardind variable declaration (C++)
- Structure Help Please (C++)
- 10, 20, 0 (C)
- I need special stuff in my project like system("cls") (C++)
- How do I create a program using an Array ? (C++)
Other Threads in the VB.NET Forum
- Previous Thread: Project idea ! !
- Next Thread: VB.Net for AutoCAD
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access arithmetic array assignment basic binary bing box button buttons center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net excel file-dialog firewall folder ftp google hardcopy image images isnumericfuntioncall listview login math memory mobile ms mssqlbackend navigate net networking opacity output peertopeervideostreaming picturebox picturebox1 plugin port print problemwithinstallation project record reports" save savedialog searchbox serial soap sorting sql string tcp temp text textbox timer toolbox trim updown upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf





