|
I thougth IIF was something special, like if the condition is true ,the false part is never reached.
But it's nothing more than this:
Public Function IIF(ByVal condition As Boolean, ByVal truepart As Object, ByVal falsepart As Object) As Object
If condition Then
Return truepart
Else
Return falsepart
End If
End Function
|
|
|
|
|
Yep. IIF is a function that returns a single type, just like any other.
The reason why VB.NET let's you get away with some of this stuff at compile time is because, by default, VB will try to provide implicit conversions to what it thinks the expected types should be where as C# will not.
Like Luc said, the way to avoid this is Option Strict On .
|
|
|
|
|
In VB9 (VS 2008) and beyond use the new VB ternary operator (which provides exactly the same behavior as the ternary conditional operator in C#, C++, and Java) rather than the 'IIf' function:
Dim o = If(True, "1", CType("", Decimal))
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
An empty string cannot be converted to a Decimal so the conversion throws an error. Change the empty string to "0" and it should work just fine. If you need it to return a different type (this has the smell of a homework project) try replacing the CType block with a different value, like 0.0 or Nothing .
|
|
|
|
|
Hi,everyone! I used a treeview control in my application, I wanted to make treenodes like a href ,for example ,when my mouse move over it ,the font and color of treenode changed . I've done this in mousemove event. The code was like this
Private Sub treeQiaoTi_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles treeQiaoTi.MouseMove
Dim info As TreeViewHitTestInfo
info = treeQiaoTi.HitTest(e.X, e.Y)
If (info.Node IsNot Nothing And m_nodePre IsNot info.Node) Then
info.Node.ForeColor = Color.Violet
info.Node.NodeFont = New Font("微软雅黑", 10.5, FontStyle.Underline)
If (m_nodePre IsNot Nothing) Then
m_nodePre.ForeColor = Color.DarkBlue
m_nodePre.NodeFont = New Font(info.Node.NodeFont, FontStyle.Bold)
End If
m_nodePre = info.Node
End If
End Sub
But now, my question is ,when mouse move over unchecked treenode, I don't want them change color and font; I means how could judge treenodes whether checked or not ?
Please give me some help and suggestions !Thx a lot !
|
|
|
|
|
Every TreeViewItem has a IsSelected property. I guess you could use that to check if that particular node is checked or not.
|
|
|
|
|
Hi,Abhinav,I've done what I wanted with this judge:
If e.Node.Checked Then
First judge the treenode whether checked or not, if it checked, changed its color!
Still thank you for your suggestion!
|
|
|
|
|
Hi all.
I am using form.
there i want a tab control having 2 tabs.
In that tab control i want to add two forms in 2 tabs.
how to add a tab control in VB6.0 and how to use it?
|
|
|
|
|
You would need a reference to the microsoft tabbed dialog control (TabCtl32.ocx). Right click components -> "Components..." and add it in the Component dialog.
Good luck!
PURPOSE: Delays program execution until designated condition is indicated.
|
|
|
|
|
OK I know that but how to use it.
I want to add two forms to the tab control.
how to do this?
Can you give me help?
|
|
|
|
|
if u want to add controls in the tabs you very well can. But can you please elabrate on the point about adding 'two forms'. i am sure i can help you with this if u could tell me that.
do you mean that u have 2 forms and want it added it in a tab?
|
|
|
|
|
Maybe this could work:
Dim frm As new Form1
frm.TopLevel = False
frm.Parent = tabMain.TabPages(0)
frm.FormBorderStyle = bsNone
frm.Show()
Good luck!
PURPOSE: Delays program execution until designated condition is indicated.
|
|
|
|
|
You cannot add a form inside a Tab control
|
|
|
|
|
it sounds to me like you should be adding two frames, build all your controls on to the correct frames and then make one frame visible and the other invisible invisible when the user clicks on the relevant tab
|
|
|
|
|
Hopefully can give enough information to get pointed in the right direction.
Wrote a fairly extensive class and placed in .dll for use in a client application AND my web service. I declare the class as a one dimensional array and then try to pass into the web service; however, when I set client.class = ws.class I get a compilation error indicating that ws.class cannot be converted to client.class.
I've tried CType and DirectCast, but both complain of the same thing. Do I need to write a conversion routine in my code to parse each node of the class? There must be an easier way....
<br />
<br />
(.dll)<br />
<br />
<br />
public class Address<br />
private _x as string<br />
private _y as string<br />
get/set for x and y<br />
<br />
public sub New()<br />
_x=""<br />
_y=""<br />
end sub<br />
end class<br />
<br />
<br />
(client)<br />
<br />
dim a() as Address<br />
... read data and populate a()<br />
<br />
dim ws as new webservice.service<br />
ws.validate(a())<br />
<br />
<br />
(web service)<br />
<br />
public sub validate(byval b() as Address)<br />
<br />
<br />
<br />
When I try to run this I get a cannot convert client.a() to webservice.b() even though they implement the .dll with the same class.<br />
<br />
I don't understand what serialization does for an array, so I'm off to study how that will effect these calls. In the mean time, if someone could point me in the proper directly, it would be greatly appreciated.<br />
<br />
<br />
<br />
<br />
<br />
|
|
|
|
|
One way to accomplish this is to put the class in a dll that both sides (client/server) reference.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
I did, both client and web service use the dll. That is what has me perplexed. The message will read module1.class cannot be converted to module2.class.
|
|
|
|
|
If you using the same dll, then why is it saying different names for the class? class1 in the client is the same as class 1 in the service.
so just to clarify
you have a dll called "mysharedclasses" you webservice has a copy that it references. your client has a copy for it to reference. correct so far?
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
correct. This is the exact message:
Value of type '1-dimensional array of PNDataMap.AddressStructure' cannot be converted to '1-dimensional array of CardProgramNG.ValidateService.AddressStructure' because 'PNDataMap.AddressStructure' is not derived from 'CardProgramNG.ValidateService.AddressStructure'.
|
|
|
|
|
Of course PNDataMap.AddressStructure and CardProgramNG.ValidateService.AddressStructure are different types, even their namespaces are different. If they were the same type, the whole namespace mechanism wouldn't make any sense at all.
|
|
|
|
|
which begs the question, how do I pass a class through to a web service?
|
|
|
|
|
how do you serialize, and later deserialize some object? by using the same type, i.e. the same assembly, for both operations, whether they are executed by one or more processes. A web service doesn't change that. If one party has set the type, the other party has to agree on using the same type.
|
|
|
|
|
Good question - how do you serialize the object? As stated in the opening question, I have never had to serialize anything - meaning no experience.
|
|
|
|
|
Then start by studying the subject. Read the relevant chapter in your C#/VB.NET book, then go and look for some of those excellent CodeProject articles, and finally apply what you have learned. You're probably too old for spoon feeding anyway.
|
|
|
|
|
Hi Friends,
I am creating an xml file with excel vba. Now I wanted to add attributes to the xml child nodes..Please kindly help..
Thanks in advance
Regards,
Priya.
|
|
|
|