Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

select case

Posted on 1999-01-27
6
Medium Priority
?
149 Views
Last Modified: 2010-05-03
I'm making a calculator that requires the input of two out of seven variables. I figure there are about 42 possible combinations. I started by just using if , elseif etc. but quickly had such a mess I lost track of where I was. I'm thinking that maybe selsct case would be the way to go, but I've never used that before, could someone show me or have a better method. I'm using VB4 pro 16bit, my input variables are text6 - 12.
Thanks
0
Comment
Question by:ralphy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 14

Accepted Solution

by:
waty earned 300 total points
ID: 1470873
Select Case Text6.Text
    Case "1":
           .....
    Case "Log":
          .....
    Case "+":
          .....
    Case Else
        ' *** Otherwise
End Select
0
 
LVL 3

Expert Comment

by:jjbyers
ID: 1470874
Change your text boxes to a control array. Change the index on text6 to 0, then change the name of the rest to text6 and answer yes about a control array.

Use this code to check the text boxes

Dim var1() As String
Dim licnt As Integer
Dim licnt1 As Integer

  licnt1 = 0
  For licnt = 0 To 6
    If Len(Text6(licnt)) <> 0 Then
      ReDim Preserve var1(licnt1)
      var1(licnt1) = Text6(licnt)
      licnt1 = licnt1 + 1
    End If
  Next licnt
  Debug.Print licnt1
  For licnt = LBound(var1) To UBound(var1) - 1
    Debug.Print "A " & var1(licnt)
  Next licnt

Hope this helps.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1470875
I agree that this is a case for a control array. Normally I'd set up a counter var and then sequence thru all of the controls in the array and increment the counter if one of the controls is non-blank. At the end of the loop, if the counter var is >=2 then you'll know at least two of your fields have been filled.

countvar = 0
for ndx = LBound( Cmd_array ) to UBount( Cmd_Array )
   if len( cmd_Array( ndx ).Text ) > 0 then countvar = countvar+1
next ndx
if countvar >1 then
 ... do stuff ...
else
 ... don't do stuff ...
endif

M

M

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:toys032498
ID: 1470876
Take a look at using Tags!  Check it out!
Anthony
0
 

Author Comment

by:ralphy
ID: 1470877
waty
    I don't understand what the four cases are or mean, please explain in a little bit of detail.
   Thanks
Ralphy
0
 
LVL 14

Expert Comment

by:waty
ID: 1470878
the value after the case are all the possible value. I will show you another example where you normally use an IF :

Select Case chkShowDetails.Value
        Case 0 :  '*** Unchecked
             frmDetails.Visible=False

        Case 1 :  '*** Checked
             frmDetails.Visible=True
             frmDetails.Show

        Case 2 :  '*** Grayed
             frmDetails.Visible=True
             frmDetails.Enabled=False
             frmDetails.Show

    End Select

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question