|
-
Feb 3rd, 2004, 10:20 PM
#1
Thread Starter
Lively Member
one line assignment [solved]
halu,
i'm kinda confuse about one line initialization... this gives me a "not i want" output...
VB Code:
cmbCategoryStatus.Text = cmbMakersStatus.Text = String.Empty
is there a bug? i really don't know... it doesn't clear at all. it just clears the cmbMakersStatus and put "True" to cmbCategoryStatus.Text. is this supported in VB.NET -- the one line initialization?
it also has no effect with integers either... like
just want to clarify if VB supports this kind of initialization...
thanx
Last edited by ayan; Feb 4th, 2004 at 12:54 AM.
-
Feb 3rd, 2004, 10:40 PM
#2
Thread Starter
Lively Member
halu,
i guess VB.net doesn't support what i want. i queried this on msdn abot operators
Used to assign a value to a variable or property.
variable = value
Parts
variable
Any variable or any writable property.
value
Any literal, constant, or expression.
Remarks
The name on the left side of the equal sign can be a simple scalar variable, a property, or an element of an array. Properties on the left side of the equal sign can only be those properties that are writable at run time. When used, the value on the right side of the equation is assigned to the variable on the left side of the equation.
Example
This example demonstrates use of the assignment operator. The value on the right side of the expression is assigned to the variable on the left side of the expression.
Dim myInt as Integer
Dim myString as String
Dim myButton as System.Windows.Forms.Button
Dim myObject as Object
myInt = 42
myString = "This is an example of a string literal"
myButton = New System.Windows.Forms.Button()
myObject = myInt
myObject = myString
myObject = myButton
examples only categorize about one variable to be assigned to one variable... i don't know... some ideas are still welcome...
thanx
-
Feb 3rd, 2004, 10:44 PM
#3
Neither of those lines initialize anything they just assign things. An example of one line initializing would be:
VB Code:
Dim str As String="I'm Initialized!"
'instead of
Dim str As String
str="I'm Initialized!"
What is it you are trying to do?
-
Feb 3rd, 2004, 10:46 PM
#4
Thread Starter
Lively Member
ooops, sorry wrong word used... what i meant is assignment. is there any way of one assignment...
like the one i post earlier... i=j=0
sorry... is this supported in VB? like the ones in java or c...
thanx very much...
-
Feb 4th, 2004, 12:41 AM
#5
No I'm afraid it's not. What is the purpose of that in Java? OR is it just a handy shortcut?
-
Feb 4th, 2004, 12:50 AM
#6
Thread Starter
Lively Member
sort of... i'm a newbie though. hehe. but i encounter this in java or c. like assignment of i and j on a single line. we would normally do that. like i=j=0. just wondering if it's possible in vb but thanx for the information. i even search msdn and no luck at all. i would like to assign two combo boxes' text a string empty.
i guess i found the answer right now. thanx Edneeis...
thanx times ten to the power of forever...
-
Feb 4th, 2004, 03:46 AM
#7
Sleep mode
C# perfectly accept this kind of assignment .
But if you want to set any property for similar controls on your form , then use this code for example to clear the text in all the comboboxes on your form .
VB Code:
Dim CBox As Control
For Each CBox In Me.Controls
If TypeOf CBox Is ComboBox Then
CBox.Text = String.Empty
End If
Next
-
Feb 4th, 2004, 03:52 AM
#8
Thread Starter
Lively Member
halu,
thanx, so much... i tried that... that works man. very well...
thanx times ten to the power of forever...
--ayan
-
Feb 4th, 2004, 03:54 AM
#9
I don't think you can do that in C#. He means:
VB Code:
TextBox1.Text=TextBox2.Text=String.Empty
-
Feb 4th, 2004, 03:56 AM
#10
Sleep mode
Originally posted by Edneeis
I don't think you can do that in C#. He means:
VB Code:
TextBox1.Text=TextBox2.Text=String.Empty
Did you try it Ed ?
-
Feb 4th, 2004, 03:58 AM
#11
-
Feb 4th, 2004, 04:00 AM
#12
And that assigns String.Empty to both textboxes? If so that's cool I didn't realize you could do that in C#. Right on Pirate!
-
Feb 4th, 2004, 04:02 AM
#13
-
Feb 4th, 2004, 04:04 AM
#14
It compiles but doesn't work as expected in VB. It is interepted as textBox1.Text=(TextBox2.Text=String.Empty) and makes the text for textbox1 =False.
-
Feb 4th, 2004, 04:07 AM
#15
Thread Starter
Lively Member
i tried doing C# the first time of my life. gosh.... i'm kinda newbie though... it works with me
Code:
private void button1_Click(object sender, System.EventArgs e)
{
textBox1.Text=textBox2.Text=string.Empty;
}
thanx to all... hehehe..
-
Feb 4th, 2004, 04:10 AM
#16
Sleep mode
Originally posted by ayan
i tried doing C# the first time of my life. gosh.... i'm kinda newbie though... it works with me
This proves C# isn't VB , It's the little son of C/C++ . .....
-
Feb 4th, 2004, 04:12 AM
#17
I read that C# was really intended to help people adapt from Java to .NET so really I guess it makes sense that it can be done there since it can be dnoe in Java.
Just my 2 cents.
-
Feb 4th, 2004, 04:16 AM
#18
Sleep mode
Could be true but I'd stop at this point and agrue no more since this topic would drive this thread crazy lol .
-
Feb 4th, 2004, 04:17 AM
#19
Thread Starter
Lively Member
yezzz. kinda wondering that before but just asking if it's in VB. so now, i learn something... i tried C, Java before but just basics. anywayz, thanx to all of you guys... thank you thank you...
that's times ten to the power of forever...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|