Can this be done in vb.net and how?

R

Ron

Can something like this be done?

Say I have two buttons a Prepare and Calculate button.

when the user hits Prepare, it looks to combo boxes, sees what is
selected and displays apprpriate labels and text boxes and hides the
ones not needed

for example

for btnPrepare_Click......

dim var1 as string = cboSelected.text
dim var2 as string = cboSelectiontwo.text

if var1="All" and Var2="Qty" then

..... show some textboxes hide others etc.

.....
Now I also have a Calculate button and when that is pressed i want to
take values and calc them.

Can I somehow give every IF Block above a name and then use it there
for btnCalculate_Click

i dont know if this makes sense but thanks for any help
 
C

Cor Ligthert [MVP]

Ron,


Can you tell us the sense of this, it gives me the idea that you think that
calculating takes time.

Cor
 
R

RobinS

My guess is he wants to give the user different things to calculate, and
doesn't want to confuse him by having "FieldB" on the screen when it
doesn't apply to the selected calculation.

I would enable/disable or change the visibility of the controls when they
change the item in the dropdown box, and save them the trouble of clicking
a <Prepare> button.

Robin S.
 
P

Phill W.

Ron said:
when the user hits Prepare, it looks to combo boxes, sees what is
selected and displays apprpriate labels and text boxes and hides the
ones not needed .. . .
dim var1 as string = cboSelected.text
dim var2 as string = cboSelectiontwo.text

if var1="All" and Var2="Qty" then
.... show some textboxes hide others etc.

Personally, I'd hook this up to the SelectedIndexChanged event on both
ComboBoxes ...

Sub Combo_SelectedIndexChanged( ... ) _
Handles cboSelected.SelectedIndexChanged _
, cboSelectiontwo.SelectedIndexChanged
if var1="All" and Var2="Qty" then
.... show some textboxes hide others etc.

If cboSelected.SelectedIndex <> -1 _
AndAlso cboSelectiontwo.SelectedIndex <> -1 _
Then
btnCalculte.Enabled = True
Else
btnCalculte.Enabled = False
End If

End Sub
Now I also have a Calculate button and when that is pressed i want to
take values and calc them.
Can I somehow give every IF Block above a name and then use it there
for btnCalculate_Click

How about this?

Sub btnCalculate_Click( ... )

Dim sSum As String _
= cboSelected.Text & ":" & cboSelectionTwo.Text

Select Case sSum.ToLower()
Case "all:qty"
...
Case Else
Debugger.Break()
End Select

HTH,
Phill W.
 
B

Branco Medeiros

Ron wrote:
when the user hits Prepare, it looks to combo boxes, sees what is
selected and displays apprpriate labels and text boxes and hides the
ones not needed
dim var1 as string = cboSelected.text
dim var2 as string = cboSelectiontwo.text

if var1="All" and Var2="Qty" then

.... show some textboxes hide others etc.
Now I also have a Calculate button and when that is pressed i want to
take values and calc them.

Can I somehow give every IF Block above a name and then use it there
for btnCalculate_Click
<snip>

If you need the textboxes that were enabled by the Prepare button, I
guess you can save them in a form level list (say, a List(Of TextBox),
if you're using VB 2005), and the Calculate button would just iterate
by them;

Alternatively you may have a CalculateParams class, for example, which
you'd initialize while still in prepare and use in the Calculate.

HTH.

Regards,

Branco.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top