Click here to Skip to main content
15,911,711 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionSum algorithm Pin
Scott Page5-Apr-06 7:31
professionalScott Page5-Apr-06 7:31 
AnswerRe: Sum algorithm Pin
Guffa5-Apr-06 8:17
Guffa5-Apr-06 8:17 
GeneralRe: Sum algorithm Pin
Scott Page5-Apr-06 10:04
professionalScott Page5-Apr-06 10:04 
AnswerRe: Sum algorithm Pin
J4amieC5-Apr-06 9:02
J4amieC5-Apr-06 9:02 
GeneralRe: Sum algorithm Pin
Scott Page5-Apr-06 9:58
professionalScott Page5-Apr-06 9:58 
GeneralRe: Sum algorithm Pin
machman15-Apr-06 12:16
machman15-Apr-06 12:16 
AnswerRe: Sum algorithm Pin
Steve Pullan5-Apr-06 15:38
Steve Pullan5-Apr-06 15:38 
GeneralRe: Sum algorithm Pin
Scott Page6-Apr-06 2:10
professionalScott Page6-Apr-06 2:10 
Thanks for the post,

I am getting closer to my goal, but still no cigar (I mean stack). Below is the function I'm using to build the stack. In answer to you question about the 0.06" height, Block Sets are manufactured to cover nearly all possible heights seen in the manufacturing and Metrology worlds. If a value does not exist, there other methods used to measure those dimensions.

This function gets me as close as 2.203". I tested the function using 2.203" (correct result), 2.205" (still got 2.203"), 2.305" (still got 2.203"). The returned stack has the 0.101", 0.102" and 2" blocks used, so obviously, since I can't use the 0.102" block, I can't cover the last 0.102" of the height.

The Code:
<code>
'This function exists within a custom collection
Public Function GetStack(ByVal height As Decimal) As GageBlockCollection
Me.ClearUsedBlocks()
Dim Stack As New GageBlockCollection
If Me.HasEqualGageBlock(height) Then
Stack.Add(Me.GetEqualGageBlock(height))
Return Stack
Else
Dim PossibleBlocks As New GageBlockCollection
If height >= 1 Then
'Height is greater than 1", so find the block that makes eliminates the inch part
For Each Block As GageBlock In Me
If height - Block.Height > 0 AndAlso height - block.Height < 1 Then
Block.IsUsed = True
PossibleBlocks.Add(block)
height -= Block.Height
End If
Next
End If
'Find all blocks that are less than the remaining Height (the inch part has been removed)
For Each Block As GageBlock In Me
If Not Block.IsUsed AndAlso Block.Height <= height AndAlso Block.Height.ToString.Length = height.ToString.Length Then
If Block.Height = height Then
Stack.Add(Block)
Block.IsUsed = True
For Each B As GageBlock In PossibleBlocks
Stack.Add(B)
Next
Return Stack
Else
Stack.Add(Block)
Block.IsUsed = True
height -= Block.Height
End If
End If
Next
If Not height = 0 Then
For Each Block As GageBlock In PossibleBlocks
If Not Block.IsUsed AndAlso height - block.Height = 0 Then
Stack.Add(Block)
End If
Next
End If
For Each B As GageBlock In PossibleBlocks
Stack.Add(B)
Next
Return Stack
End If
End Function
</code>

"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
( President Ronald Reagan)
GeneralRe: Sum algorithm Pin
machman16-Apr-06 3:52
machman16-Apr-06 3:52 
AnswerRe: Sum algorithm Pin
Scott Page6-Apr-06 2:39
professionalScott Page6-Apr-06 2:39 
Questionhow i can redefine string Pin
Mr kilany5-Apr-06 7:09
Mr kilany5-Apr-06 7:09 
AnswerRe: how i can redefine string Pin
HaloZa5-Apr-06 7:19
HaloZa5-Apr-06 7:19 
AnswerRe: how i can redefine string Pin
FrankyT5-Apr-06 13:24
FrankyT5-Apr-06 13:24 
Questionhow can i send enter character to anothe applicatoin Pin
Mr kilany5-Apr-06 7:07
Mr kilany5-Apr-06 7:07 
AnswerRe: how can i send enter character to anothe applicatoin Pin
Chatura Dilan5-Apr-06 20:59
Chatura Dilan5-Apr-06 20:59 
QuestionAppDev Suggestions Please Pin
digicd15-Apr-06 6:09
digicd15-Apr-06 6:09 
AnswerRe: AppDev Suggestions Please Pin
J4amieC5-Apr-06 9:04
J4amieC5-Apr-06 9:04 
GeneralRe: AppDev Suggestions Please Pin
digicd15-Apr-06 9:17
digicd15-Apr-06 9:17 
Questionhow to open a binary file in VB? Pin
Mayur Gondaliya4-Apr-06 21:12
Mayur Gondaliya4-Apr-06 21:12 
QuestionUrgent help needed : Reading from a .htm file using VBScript Pin
giftsana4-Apr-06 20:30
giftsana4-Apr-06 20:30 
Questionhow to make Login Page in VB.Net Site Pin
Amit Agarrwal4-Apr-06 20:23
Amit Agarrwal4-Apr-06 20:23 
AnswerRe: how to make Login Page in VB.Net Site Pin
Chandan_Kr5-Apr-06 23:10
Chandan_Kr5-Apr-06 23:10 
Questionvb.net how to move to next tab on click of button????? Pin
Ron.S4-Apr-06 20:12
Ron.S4-Apr-06 20:12 
AnswerRe: vb.net how to move to next tab on click of button????? Pin
Dean_SF5-Apr-06 4:47
Dean_SF5-Apr-06 4:47 
AnswerRe: vb.net how to move to next tab on click of button????? Pin
machman15-Apr-06 12:26
machman15-Apr-06 12:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.