PC Review


Reply
Thread Tools Rate Thread

Can this be done in vb.net and how?

 
 
Ron
Guest
Posts: n/a
 
      2nd Feb 2007
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

 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      2nd Feb 2007
Ron,


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

Cor

"Ron" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
RobinS
Guest
Posts: n/a
 
      2nd Feb 2007
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.
-------------------------------
"Cor Ligthert [MVP]" <(E-Mail Removed)> wrote in message
news:O4G$(E-Mail Removed)...
> Ron,
>
>
> Can you tell us the sense of this, it gives me the idea that you think
> that calculating takes time.
>
> Cor
>
> "Ron" <(E-Mail Removed)> schreef in bericht
> news:(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
Phill W.
Guest
Posts: n/a
 
      2nd Feb 2007
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.


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.
 
Reply With Quote
 
Branco Medeiros
Guest
Posts: n/a
 
      2nd Feb 2007
Ron wrote:
<snip>
> 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

<snip>
> 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.

<snip>
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:58 PM.