|
It looks like you are trying to parse the string?
You can make a class that contains the information from the string:
Public Class RmtInfo
Private _width As Double
Private _height As Double
Private _wallThickness As Double
Private _outerRadius As Double
Public Sub New(size As String)
Dim s As String() = size.Split(New Char() { "x"C, "/"C})
_width = Double.Parse(s(0).Trim())
_height = Double.Parse(s(1).Trim())
_wallThickness = Double.Parse(s(2).Trim()) / Double.Parse(s(3).Trim())
_outerRadius = _wallThickness * 2
End Sub
Public ReadOnly Property Width As Double
Get
Return _width
End Get
End Property
Public ReadOnly Property Height
Get
Return _height
End Get
End Property
Public ReadOnly Property WallThickness
Get
Return _wallThickness
End Get
End Property
Public ReadOnly Property OuterRadius
Get
Return _outerRadius
End Get
End Property
End Class
Example:
Dim info As New RmtInfo("3 x 2 x 3/16")
MessageBox.Show("The height is " + info.Height.ToString())
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi please some body help I am unable to Write this line of code into VB.Net.....
picImage.PSet (r, c), RGB(clrr, clrg, clrb)
where picimage is a bitmap and r,c can be any points and Clrr,clrg,clrb are the RGB colors
if I am writing the above code in Vb.net like this...:
picImage.SetPixel(r, c, New Color(clrr, clrg, clrb))
then it Gives this Error:
"Type System.drawing.color has no Constructs"..
Please any body can Guide me...
|
|
|
|
|
This isn't a post a question get a immediate response. Members check and respond to the questions when they get to them. You already asked this question below so stop spamming the boards.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Read the error message, use objectbrowser
|
|
|
|
|
I am making a app that searches for some fles and i need some help finding the right commando. i am using VS 2005
Can someone guide me?
modified on Wednesday, November 12, 2008 1:28 AM
|
|
|
|
|
I'm the commando you're looking for. I'm fluent in WB.NET, and I can find flees like nobody's business.
|
|
|
|
|
The JZ wrote: I'm the commando you're looking for. I'm fluent in WB.NET, and I can find flees like nobody's business.
Classical. Amazing.
|
|
|
|
|
Look at the System.IO.Directory , System.IO.File , System.IO.DirectoryInfo and System.IO.FileInfo Namespaces.
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
I have a datagridview which is bound by a typed dataset. On the initial binding typed dataset is empty. There s autoincrement column specified on the typed dataset. The grid is readonly. But whenever I click on header the autoincrement column increments. It should have occurred only if I add a new row through the code.
Can anyone tell me what is happening here?
Thanks.
|
|
|
|
|
In visual basic net I want to move highlight from row to row
|
|
|
|
|
i heave made a skin with Codejock skin builder and, i want to use it in my app. can someone help me?????
|
|
|
|
|
Have you looked through the documentation on Codejock? Surely they'd have something there.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I am working with VB.Net 2005, I have a double that is coming up as .025 and I need to round it correctly. So it should show as .03 once this is done.
I currenlty do this and it doesn't seem to work...
Dim DisTest As Double = 2.5 / 100
Round(DisTest, 2)
modified on Tuesday, November 11, 2008 11:15 AM
|
|
|
|
|
You can use the overload function Round(DisTest, 2, MidpointRounding.AwayFromZero)
|
|
|
|
|
I tried....
Dim DisTest As Double = Me.TermDiscPct / 100
Round(DisTest, 2, MidpointRounding.AwayFromZero)
and it didn't make any difference
|
|
|
|
|
The Round method doesn't change the value that you pass to it, you have to take care of the return value:
DisTest = Round(DisTest, 2, MidpointRounding.AwayFromZero)
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guffa, I caught that earlier (stated it further down in the posts).
|
|
|
|
|
Function RoundMyDouble(ByVal r As Double, ByVal places As UInt16)
Dim off As Double = Math.Pow(10, places)
Return CInt(r * off) / off
End Function
|
|
|
|
|
I tried....
Dim DisTest As Double = Me.TermDiscPct / 100
Round(DisTest, 2, MidpointRounding.AwayFromZero)
and it didn't make any difference
I don't want to create a function just for this. It seems like there should be a way to just round this with that much overhead.
|
|
|
|
|
Are you using Math.Round function?
Just to check because it works fine with me, it returns 0.03
if I use 0.025...
|
|
|
|
|
Yes I was doing that(Math.Rounding) but I wasn't resigning the variable the new value. That works just fine. Thanks!!
|
|
|
|
|
You might want to double check the results and do some testing to see if it's going to work for you. Also, doing math on the number you want to round while using a Double type can affect how rounding works.
For example, Doing something like: Math.Round(1.255, 2) results in 1.25, not 1.26. What happens is that 1.255 is multiplied by 100 (the 2 parameter), then the number is rounded to the nearest integer. But, with the Double type, this results in 1.255 * 100 = 125.4999999999, which will round DOWN to the nearest integer of 125. This is then divided by 100, which results in 1.25. If accuracy is mandatory, consider using the Decimal type. It's slower since it's not a native CPU data type, but it is more accurate.
|
|
|
|
|
Hey Dave, thanks for your reply. Doesn't MidpointRounding.AwayFromZero fix what you are refering to? I was having a similar problem that you descriped and it took care of it.
I was doing this..
Dim DisTest As Double = 2.5 / 100
Round(DisTest, 2)
And my return was .02 instead of .03 like I would expect.
Now I am doing this...
Dim DisTest As Double = 2.5 / 100
Round(DisTest, 2,MidpointRounding.AwayFromZero)
And now my return is .03 just as I would expect it to be. I am only asking because accuracy is important and it seems to be pretty accurate as of now. But are you saying if I had 1.255 / 100 then it wouldn't be accurate?
|
|
|
|
|
CCG3 wrote: Doesn't MidpointRounding.AwayFromZero fix what you are refering to?
No, it doesn't. It just happened to change the behavior of the Round method so THAT particular case worked out properly. The AwayFromZero option rounds numbers up, never down.
CCG3 wrote: And now my return is .03 just as I would expect it to be. I am only asking because accuracy is important and it seems to be pretty accurate as of now. But are you saying if I had 1.255 / 100 then it wouldn't be accurate?
Yep. The only reason why it worked is because the math using Double numbers worked out to nice even binary representations. For example, 1.255 / 100 = 0.012549999999999, not 0.01255. In your case, 2.5 / 100 worked out evenly to 0.025. It's those binary approximations that screws up the rounding. It just happened to work out properly on the example you tried. It will NOT work in all cases.
You'd probably be better off using the Decimal type instead of Double.
|
|
|
|
|
Thanks Dave, I think I understand what you are saying...
on further testing, I ran these lines just like this...
Dim DisTest As Double = 1.255 / 100
MsgBox(DisTest)
DisTest = Round(DisTest, 2, MidpointRounding.AwayFromZero)
MsgBox(DisTest)
Dim DisTest2 As Decimal = 1.255 / 100
MsgBox(DisTest2)
DisTest2 = Round(DisTest2, 2)
MsgBox(DisTest2)
They both gave the same results. (.01)
And you are saying that I would be better off to just use Decimal. The preceeding example is all I would have to change right? Instead of using Double change it to Decimal and leave out the MidpointRounding.AwayFromZero. right?
|
|
|
|