|
You don't have to do anything, you just have the initial if statement. When something isn't iffed then the function just ends. Besides, I had to include yadda yadda because I needed to add some technical lingo that no one would understand .
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Thanks!
AR Reddy
|
|
|
|
|
For starters, you seem to be mixing C# elements with VB code.
Second, assuming that imlMain is an image list, the .Net version does not have a default property. Because of this, you must explicitly reference the Images collection.
Third, DefInstance is a hack Microsoft added to the .Net framework to manage code translated from VB6. Assuming that this method is inside the form being referenced, this should work:
Public Sub abcd(ByRef element As System.Windows.Forms.Control)
CType(element, PictureBox).Image = Me.imlMain.Images("Image1")
End Sub
Properly, though, you should make sure that element really is a PictureBox. The easiest way to do this is with TryCast rather than CType. They do the same basic thing, but TryCast will return Nothing if the conversion fails. Your method would then look like this:
Public Sub abcd(ByRef element As System.Windows.Forms.Control)
Dim PB As PictureBox = TryCast(element, PictureBox)
If PB IsNot Nothing Then PB.Image = Me.imlMain.Images("Image1")
End Sub
|
|
|
|
|
As far I as I am concerned (since I do this to), a mix of multiple languages to convey a clear message is considered a type of pseudocode. You don't have to know any particular language to understand the basics of pseudocode.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Just covering all the bases.
|
|
|
|
|
Here is a little code snippet...
Private Sub TextNet_Change()
If TextNet <> "" Then
Dim DCalcVat As Long
Dim DCalcGross As Long
Dim DCalNet As Long
DCalcNet = TextNet
LabelFrameNet = DCalcNet
DCalcVat = DCalcNet / 100 * 17.5
TextVat = DCalcVat
DCalcVat = TextVat
LabelFrameVat = TextVat
DCalcGross = DCalcNet + TextVat
TextGross = DCalcGross
LabelFrameGross = DCalcGross
End If
End Sub
I want the TextBox (TextGross) and the Lable (LabelFrameGross) to both show the final DCalcGross value.
(I know it is Dim'd as a Long, but I tried Double wich is why it is currently a (D)CalcGross)
Am I missing something here?
------------------------------------
"I want you to imagine I have a blaster in my hand" - Zaphod Beeblebrox.
"You DO have a blaster in your hand" - Freighter Pilot
"Yeah, so you don't have to tax your imagination too hard" - Zaphod Beeblebrox
|
|
|
|
|
TextBox = format(DCalcGross, "0.00")
LabelFrameGross = format(DCalcGross, "0.00")
Tim
|
|
|
|
|
Thank you my friend.
It is amazing how easy that was, I don't know why I didn't get there myself.
I must have been having a "Dim" day!
------------------------------------
"I want you to imagine I have a blaster in my hand" - Zaphod Beeblebrox.
"You DO have a blaster in your hand" - Freighter Pilot
"Yeah, so you don't have to tax your imagination too hard" - Zaphod Beeblebrox
|
|
|
|
|
Sorry, this is a stupid question.
I have a class library project stored in a file "c:\test1" It creates a .dll named test1.dll. I want to rename the entire project and assembly to "final" which will create "final.dll". I'm finding that if I copy the project to a different folder I can't load it. What's the solution. Basically I want to "save project as..."
Thanks
|
|
|
|
|
You need to change the solution properties.
VS2008:
1) Right-click project properties
2) Edit Assembly Name
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
|
Hi
I want to access the items added in the list box or combo box on right click.
Example
List box contains:
ITEM(0)"First"
ITEM(1)"Second"
ITEM(2)"Third"
values have been populated and program is running now i "Right Click" on list box
what i want , the index number of the item on which mouse was Right clicked.
Thanx in anticipation
Riaz Ahmed
0300-2668545
Software Engineer
DCCTechnologies
riaz.ahmed@dcc.com.pk
|
|
|
|
|
On mouse up event of list box you can use IndexFromPoint method to get index of item which has been clicked. This index can be used to retrieve the actual listbox item, such as –
------------------------------------------
Private Sub ListBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseUp
Dim ItemName As String
If e.Button = Windows.Forms.MouseButtons.Right Then
ItemName = Me.ListBox1.Items.Item(Me.ListBox1.IndexFromPoint(e.X, e.Y)).ToString()
MessageBox.Show(ItemName)
End If
End Sub
-------------------------------------------
I hope this helps .
-Dave.
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
Hi All,
I want to check the menuitem visibilty. Menu items will be coming through recordset and will loop through the recordset. For each menuitem, I want to check the visibility like as follows.
frmMain.DefInstance.Controls(rstRef.Fields("cname")).Visible
but, abouve code is giving cast error.
if we hardcode the menu Item, its working fine. like as follows
frmMain.DefInstance.MenuItem1.Visible
But, if I want to check the menu item visibilty dynamically, how can I do?
Please let me know.
Thanks in Advance.
AR Reddy
|
|
|
|
|
for each mi as menuitem in frmmain.definstance.controls
if mi.visible = true then
'your code
end if
next
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Hi Jones,
Thanks a lot. Its working with little bit modifications. Thanks again.
AR Reddy
|
|
|
|
|
Hi Smithers-Jones,
With the given code is working fine but, its looping through all the menuitems that are in the form. But I want to checkfor few menus (that will come from recordset) only.
so from your given code, if I check mi.Name, Im not getting menu name.
like as follows,
Dim str as String = recset("cname")
for each mi as menuitem in frmmain.definstance.controls
if mi.Name == str
if mi.visible = true then
'your code
end if
next
So i am not able to check visibility property for few menu items.
How can I do this. Please let me know the solution if you get a chance to look into this.
Thanks in Advance,
AR Reddy
|
|
|
|
|
Not a problem, but was woundering how do you deside whether to use a function or a property, especially if they are private?
Comments, guidance ans in-sights if you please.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Generally, properties are used to represent the state of an object and have few if any side effects when set, and functions are used to get something that will require a lot of calculation. FxCop will also tell you that you should never return an array from a property, but I do not always agree (especially for databinding).
There are no hard and fast rules, but there are a few things I would consider when making the choice. (I'm sure a quick Google search would find plenty of other opinions)
1) Will you both get and set the value? (if yes, +1 for property)
2) Will you only get the value? (could go either way)
3) Will you only set the value? (if yes, I would always make this a function. Write-only properties do not make much sense to me)
4) Are you going to need to databind to this value? (if yes, you will probably be required to make this a property)
5) Would the Get/Set functions be simple? (if yes, +2 for property)
Simple is of course subjective, but generally it means something like this:
Get
Return _memberVar
End Get
Set (value as YourTypeHere)
If value = _memberVar Then Exit Property
_memberVar = value
OnPropertyNameChanged()
End Set
and the OnPropertyNameChanged would raise any events and perform any other state changes that come from setting the property (eg: when PropertyA to false, PropertyB must be 0).
|
|
|
|
|
A few more points to consider, IMHO:
-1- When an attribute is written, is the value likely to remain set indefinitely absent user intervention (things like controls may be changed by the user--that's their purpose).
-2- Will writing the attribute with the value it already contains have any effect (if so, use a method)
-3- Will writing this attribute have side-effects on other writable properties that are not subsets or supersets? There's nothing wrong with an object having properties for, e.g., X, Y, and position; changing position will update both X and Y; changing X or Y will update position. On the other hand, the 'length' property for a StringBuilder is ugly, since reducing the length has the side-effect of clearing some (or all) of the contents.
-4- Will reading this attribute have any side-effects other than possibly caching, or will it require access to a resource guarded by a mutex or synclock? If so, use a method.
-5- IMHO, some attributes should use a method for writing and a property for reading. For example, if I were designing the timer object, I would have included a TimeLeft property (read-only) and a SetTimeLeft method (possibly an AddTime method as well). The time remaining on a timer is apt to change as soon as it's written, so I don't like the idea of using a writable property for that; nonetheless, since the remaining time represents the object's logical state, a read property seems appropriate.
|
|
|
|
|
I use two criteria: Will it behave like a variable or like a function? If it will behave like a variable, do I need to do anything other that store/retrieve the data?
If all I need is some place to store data, I will write a private variable declaration; if I don't need to do the extra coding, I don't. If the value is static, I write a private constant declaration.
Private X As Integer
Private Const CaptionText As String = "Enter some data" If the value is dynamic and read-only, then I will write a private function.
Private Function FolderPath() As String
Return String.Format("{0}\{1}", PathTextbox.Text, FileTextbox.Text)
End Function
If I need to validate the data when it is retrieved or stored, do some other kind of processing or perform multiple operations with that value, that is when I will write a private property with at least a Get.
Private pStringList As List(Of String)
Private ReadOnly Property StringList() As List(Of String)
Get
If pStringList Is Nothing Then pStringList = New List(Of String)
Return pStringList
End Get
End Property
Private pMyHeight As Integer
Private Property MyHeight() As Integer
Get
Return pMyHeight
End Get
Set(ByVal value As Integer)
Dim H As Integer = MinHeight
If value > MaxHeight Then
H = MaxHeight
ElseIf value > MinHeight Then
H = value
End If
pMyHeight = H
ResizeMe()
End Set
End Property
|
|
|
|
|
Hi experts,
I have a typed dataset in my VB.Net project, where I use to add tables at
design time. Bydefault there are only four properties for the tables
like.. CaseSensitive, DisplayExpression, Locale and Name.
Here, my requirement is, I need three more user defined properties for as
many tables as I added at design time and in the same manner I need three
more user defined properties for the columns in the tables.
I hope, that my requirement is clear and I am awaiting for your help
Thanks a lot in advance to all who helps me
Ravi Shanker .L
|
|
|
|
|
Sounds like you want to derive a new class from the class that defines your tables now ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Thanks for the response
Its nothing like "derive a new class from the class that defines my
tables"
I just want to use the dataset designer to visually create and edit tables
and as well i need more properties at the same time. I can explain you a
bit clearly. Take a new VB.Net project, add new item to the project and
select 'Dataset'. There after, right click on the dataset area, select
Add -> DataTable from the popup menu, you are going to get a table with
no columns, right ?. Now, right click on the table and select properties
from the popup menu, a properties window is going to appear there are only
four properties bydefault right ?. But, i want some more properties there
Once again thanks for the response and I am awaiting for another response
Ravi Shanker .L
|
|
|
|
|
I think you'll probably find that Christian's answer is correct - there's no way to make properties 'magically' appear in the property window. You have to have a way of putting them there, and deriving another class with further public properties from the datatable class could be one way to go. Mind you, you might want to consider your design in general...
|
|
|
|
|