|
I have several usercontrols that inherit from an other control.
I need to be able to set a property for all these (and other) controls.
But I don't really want to be writing a select case for all these controls, is there any way to know the type of the 'base' control?
|
|
|
|
|
I have some extended controls (tabcontrols, textboxes, etc).
I use checks like:
For Each oControl As Control In fraOffsets.Controls
With oControl
If TypeOf oControl Is TextBox Then
'Do work here....
End If
End With
Next
All textboxes on this frame are extended, but pass because they are all of type textbox. If your talking about a composite control, I don't know - other than you might set a property to designate it (like Tag or create one).
Did either of these suggestions work for you TDDragon?
modified on Friday, July 25, 2008 2:48 PM
|
|
|
|
|
I'm looking for any advice on what is a good barcode scanning device that is easy to use with VB2005. I'm thinking of developing an application that would read a Fed Ex barcode and update one of our internal systems with the tracking number. Thank you.
|
|
|
|
|
AFAIK most barcode scanners act as a second keyboard, that is they emit text as
if it was typed. With often the option to prefix and append two selectable literal strings,
so you can differentiate a scan result from simple typing.
|
|
|
|
|
I have code like
Dim subject As String = "Test EmbeddedImage"
Dim contentId As String = "image1"
Dim body As String = "Here is a picture of CRM:
Dim av1 As AlternateView = AlternateView.CreateAlternateViewFromString(body, Nothing, "Text/Html")
Dim linkedResource1 As LinkedResource = New LinkedResource(ms,?????)
linkedResource1.ContentId = contentId
av1.LinkedResources.Add(linkedResource1)
.
.
other code for sending mail
.
.
What should I write at ????
for sending mail with image ?
|
|
|
|
|
please read carefully ...
I have a Picture box on the form ...
and I want to send that image with mail which appears in pictute box
Now I have a code that takes the image from folder structure
like c:\temp\aaa.jpg
It sends image with mail PERFECTLY....
but now I have to send mail which is store in memory stream .
not in file...
I have code
like
How can I send the image wich stored in memory stream ???
I have code
like
Public sub senmail(ByVal image1 as Image)
Dim subject As String = "Test EmbeddedImage"
Dim contentId As String = "image1"
Dim body As String = "Here is a picture of CRM:
Dim ClientPC As New SmtpClient("ddd.com", 25)
Dim Authentication As New Net.NetworkCredential("nmy@myserver.com", "password")
ClientPC.Credentials = Authentication
Dim mSender As New MailAddress("nmy@myserver.com")
Dim mReceiver As New MailAddress("nmy@myserver.com")
Dim sMail As New MailMessage(mSender, mReceiver)
sMail.Subject = "Testing embedded image 25 july 3.41 PM"
Dim av1 As AlternateView = AlternateView.CreateAlternateViewFromString(body, Nothing, MediaTypeNames.Text.Html)
Dim ct, ct1 As New ContentType
Dim ct2 As New ContentType("image")
ct.MediaType = MediaTypeNames.Image.Jpeg
Dim linkedResource1 As LinkedResource = New LinkedResource(ms, ct.MediaType) <----- gives error here
linkedResource1.ContentId = contentId
av1.LinkedResources.Add(linkedResource1)
sMail.AlternateViews.Add(av1)
sMail.IsBodyHtml = True
ClientPC.Send(sMail)
end sub
|
|
|
|
|
nileshbahirshet wrote: Dim ct, ct1 As New ContentType
Try this instead:
Dim ct As New ContentType
Dim ct1 As New ContentType
IIRC, your way of definition means that ct is untyped in VB...
|
|
|
|
|
I'll try to explain :
look this example :
Module
Module1
Sub Main()
Dim num AsDouble = 1.25
Console.WriteLine(Math.Round(num, 1, MidpointRounding.AwayFromZero))
num = 1.225
Console.WriteLine(Math.Round(num, 2, MidpointRounding.AwayFromZero))
num = 1.2225
Console.WriteLine(Math.Round(num, 3, MidpointRounding.AwayFromZero))
num = 1.22225
Console.WriteLine(Math.Round(num, 4, MidpointRounding.AwayFromZero))
num = 1.222225
Console.WriteLine(Math.Round(num, 5, MidpointRounding.AwayFromZero))
num = 1.2222225
Console.WriteLine(Math.Round(num, 6, MidpointRounding.AwayFromZero))
EndSub
End
Module
The output of this sample console application is :
1,3
1,23
1,223
1,2223
1,22222
1,222223
Is there something wrong ?
In my application I must use five decimal digits and this round method.
Regards
Andrea
|
|
|
|
|
No, there isn't anything wrong with the Round method. The problem is your expectations on the double data type.
You think that you are putting the exact value 1.222225 in the variable, but that number (as most numbers) can not be exactly represented as a double . What you are actually putting in the variable is something very close to that value, something like 1.22222499999834 , which does of course round to 1.22222 .
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: You think that you are putting the exact value 1.222225 in the variable, but that number (as most numbers) can not be exactly represented as a double. What you are actually putting in the variable is something very close to that value, something like 1.22222499999834, which does of course round to 1.22222.
Is there any function to increase a double by the smallest possible non-zero amount? I would expect one could do something like:
Function BumpDouble(ByVal Num As Double) As Double
Dim Delta, NewVal As Double
Delta = Num / 36028797018963968 ' (2^55)
If Delta <> 0 Then
Do
NewVal = Num+Delta
Delta *= 2
Loop While Num = NewVal
Else
' Need special handling for really really small numbers
End If
Return NewVal
End Function
But that seems a bit hokey.
|
|
|
|
|
Rather than try to compute Delta , use Double.Epsilon instead - then you could just do Num + Delta .
|
|
|
|
|
Stuart Dootson wrote: Rather than try to compute Delta, use Double.Epsilon instead - then you could just do Num + Delta.
The smallest delta value for a given number will only equal Double.Epsilon if the number is very close to zero. In practice, it will always be equal to either the number divided by a particular power of two, or (if that division yields zero) Double.Epsilon; any assumption about the power of two in question, however, may break portability if future machines support higher-precision numerics.
|
|
|
|
|
You could try using the DECIMAL type instead of DOUBLE. It is much more accurate, however, a bit slower in use. This should get rid of most of these errors as explained by Guffa
|
|
|
|
|
It looks to me liek the round function is working correctly
for example for three decimal places
1.2225
since the last digit is 5 the number is rounded up to 1.223
my understanding of round is that a number is rounded down if the digits past the rounding point is 00 <= digits < 50
and rounded up if the digits past the rounding point is 50 <= digits < 100
Steve
|
|
|
|
|
You are missing the point. Notice the value 1,22222 that seems to be rounded differently from the others.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yeah actually single(float) and double are working the same way, it's not precise, because it's floating-point numbers representation. So it's a lot better and precise to use fixed-point number representation = Decimal in .Net
-- Everything is possible, even the impossible! ^_^
|
|
|
|
|
Use integer math with normalized integers and there is no problem.
Added bonus - it's a gazillion time faster than floating point math.
Divide by 10^5 before displaying to humans.
CICCIOLO69 wrote: In my application I must use five decimal digits and this round method.
Teacher evidently wants you to think a little, knowing the problem exists.
Gary
|
|
|
|
|
The Round method does not use what most of the community expects the Round method to use with regards to its function. The reason being is because the Round method rounds to the nearest even integer, in a link following you will see it is termed: the bankers method. The Round method has two options: MidpointRounding.ToEven or MidpointRounding.AwayFromZero. Neither of these is exactly what a user may want to see. You may find a better here[^], at this URL (found by google) their is a custom function that should round based on what most of the community expects. I have no idea why Microsoft chose non-standard forms of the Round function.
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
|
|
|
|
|
i have a web application that uses role/membership provider.i design the menu according to dep/role like
HelpDesk Account Stock Admin
enqury daybook jobbin createuser
appiontment balance mandate removeuser
caution updateuser
setup info
at present i can only a sign role base only. that is somebody in helpdesk will use only the submenu under hlpdesk.
i can also make sombody to be multiple role.
question
1 how can be able to deny a person in account for example access to balance submenu. that assign access on pages basis
2 load menu base on user right
any suggestion will be appriciated
|
|
|
|
|
Assuming your are using ASP.NET and your user permissions are stored in a database table, you would need to add your menu control with no options to your webpage/usercontrol and then in the Page.Load event add the options to the menu in accordance with your user's permissions, but only if IsPostBack = False
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
i have use that aporoch of form load . is there a better approach
|
|
|
|
|
I am designing an application that will be able to read and write XML files. The XML Files use XML formatting with a Document Type Definition.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE scheme SYSTEM "scheme.dtd">
<scheme date="20060312">
<title>Example Scheme</title>
<description>This is an example scheme</description>
<drawers>
<drawer id="d1" label="Drawer 1"/>
<drawer id="d2" label="Drawer 2"/>
<drawer id="d3" label="Drawer 3"/>
<drawer id="d4" label="Drawer 4"/>
<drawer id="d5" label="Drawer 5"/>
<drawer id="d6" label="Drawer 6"/>
<drawer id="d7" label="Drawer 7"/>
<drawer id="d8" label="Drawer 8"/>
</drawers>
</scheme>
I haven't ever worked with XML in VB.. (Either VB6 or .NET)
I am using VB.NET 2005.
I need to be able to read the attributes into text boxes dynamically.
The number of Drawers is Dynamic so it could be anything from 1 to 1000.
Each row would need to contain the ID and Label. Sort of like a grid view.
Does anyone have any pointers on where I should start? I can load the XML file and show it in a treeview or a single textbox, but I cannot seem to figure out how to pull the attributes only. I know the XML file is strange since it uses no Text between brackets, just attributes inside the brackets.
Thanks,
Andrew Streetman
|
|
|
|
|
I would normally treat the XML as a datatable, even to the point where I would create the initial data in a datatable by adding columns and rows and then write it out using dataset.writexml(). This would then allow you to use the standard binding methods. Additional benifit, if you ever decide to go to a database you already have the schema.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi
I have a text file which has thousands of records, I am opening it and populating it in dataset and then binding to a binding source. Then I am supposed to find specific item in specific column. In my scenario, I have to search thousands of strings within thousands of records in one routine. Currently I am using:
BindingSource1.Find("ColName","String")
Basically it is not taking much time but when it comes to thousands of records then it is taking approx 1 hour for one complete routine. (Some inside processing is also there but if records are lesser, I mean around 4,000 then it doesn't take much time but when it comes to 20,000 records then it just take me to the HELL and the PC is also at its highest, nothing else can be done however I am using multi-threading.)
What I basically want to know is that is there any way to search specific strings in a more powerful way to allow me better processing.
Any help will be highly appreciated.
Regards,
MAP Tiger
Tiger Softwares
Software Designer and Developer
VB.NET, ASP.NET, VFP
|
|
|
|
|
So first you loop through all the strings without looking for the string, then you do it again just to find the string? Doesn't that sound like a waste of time?
Skip the DataSet and the BindingSource, just read the file and look for the string.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|