Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:24:40+00:00 2026-06-11T08:24:40+00:00

Currently I have the same code in each Case statement and sometimes I have

  • 0

Currently I have the same code in each Case statement and sometimes I have to repeat it 50 times, is there a way to simplify this:
For each one I am having to create 40 frames each one names VarFrame1…VarFrame40 as well
I am creating this code in Visual Basic 6.5 in Excel

For iVar = 1 To nrVars
    Select Case iVar
    Case 1
        VarFrame1.Caption = varInfo(iVar).varName
        VarFrame1.Top = lastRow
        VarFrame1.Left = leftMargin
        VarFrame1.Height = 12
        VarFrame1.Visible = True
    Case 2
        VarFrame2.Caption = varInfo(iVar).varName
        VarFrame2.Top = lastRow
        VarFrame2.Left = leftMargin
        VarFrame2.Height = 12
        VarFrame2.Visible = True

.... to Case 50

End Select

 lastRow = lastRow + 15

    Dim res As Boolean
Select Case varInfo(iVar).varType
    Case "RadioButton"
        nrOptionButtonVals = nrOptionButtonVals + 1
        res = SetUpOptionButtons(lastRow, iVar, nrOptionButtonVals, varInfo(iVar).varOptions, varInfo(iVar).varOptionText, False)
    Case "RadioButtonOther"
        nrOptionButtonVals = nrOptionButtonVals + 1
        res = SetUpOptionButtons(lastRow, iVar, nrOptionButtonVals, varInfo(iVar).varOptions, varInfo(iVar).varOptionText, True)
    Case "DropDown"
        res = SetUpDropDown(lastRow, iVar, varInfo(iVar).varOptions, varInfo(iVar).varOptionText)
    Case "CheckBox"
        nrCBButtonVals = nrCBButtonVals + 1
        res = SetUpCBButtons(lastRow, iVar, nrCBButtonVals, varInfo(iVar).varOptions, varInfo(iVar).varOptionText, False)
    Case "CheckBoxOther"
        nrCBButtonVals = nrCBButtonVals + 1
        res = SetUpCBButtons(lastRow, iVar, nrCBButtonVals, varInfo(iVar).varOptions, varInfo(iVar).varOptionText, True)
    Case "TextEntry"
        res = SetUpTextEntry(lastRow, iVar, varInfo(iVar).varType, varInfo(iVar).varOptions, varInfo(iVar).varOptionText)
    Case "DateEntry"
        res = SetUpTextEntry(lastRow, iVar, varInfo(iVar).varType, varInfo(iVar).varOptions, varInfo(iVar).varOptionText)
    Case "NumberEntry"
        res = SetUpTextEntry(lastRow, iVar, varInfo(iVar).varType, varInfo(iVar).varOptions, varInfo(iVar).varOptionText)
    End Select
    lastRow = lastRow + 10
Next iVar
QuitButton.Top = lastRow
lastRow = lastRow + 30
PhraseDisplay.Height = lastRow + 50

DisplayCorrectedPhrase
SetUpForm = True
End Sub

Updated with Tim Williams Comments:

Public Function SetUpForm(ByRef thePhrase As String) As Boolean
    Dim nrVars, iVar, lastRow As Integer

    nrVars = Utilities.getNrPhraseVariables(thePhrase)
    ReDim varInfo(0 To nrVars)
    PhraseBoxOriginal.Text = thePhrase

    For iVar = 1 To nrVars
    varInfo(iVar).varName = Utilities.getPhraseVariable(thePhrase, iVar)
    varInfo(iVar).varIndex = PhraseVars.getPhraseVarIndex(varInfo(iVar).varName)
    varInfo(iVar).varType = PhraseVars.getTypeFromIndex(varInfo(iVar).varIndex)
    varInfo(iVar).varOptions = PhraseVars.getOptionsFromIndex(varInfo(iVar).varIndex)
    varInfo(iVar).varOptionText = PhraseVars.getOptionTextFromIndex(varInfo(iVar).varIndex)
    varInfo(iVar).varValue = Utilities.getVarOption("", 0) ' Get the default option string
    Next iVar

    nrOptionButtonVals = 0
    lastRow = 115
    For iVar = 1 To nrVars

      With Me.Controls("VarFrame" & iVar)
        .Caption = varInfo(iVar).varName
        .Top = lastRow
        .Left = leftMargin
        .Height = 12
        .Visible = True
      End With

    Next iVar
        lastRow = lastRow + 15

        Dim res As Boolean
    Select Case varInfo(iVar).varType
        Case "RadioButton"
            nrOptionButtonVals = nrOptionButtonVals + 1
            res = SetUpOptionButtons(lastRow, iVar, nrOptionButtonVals, varInfo(iVar).varOptions, varInfo(iVar).varOptionText, False)
        Case "RadioButtonOther"
            nrOptionButtonVals = nrOptionButtonVals + 1
            res = SetUpOptionButtons(lastRow, iVar, nrOptionButtonVals, varInfo(iVar).varOptions, varInfo(iVar).varOptionText, True)
        Case "DropDown"
            res = SetUpDropDown(lastRow, iVar, varInfo(iVar).varOptions, varInfo(iVar).varOptionText)
        Case "CheckBox"
            nrCBButtonVals = nrCBButtonVals + 1
            res = SetUpCBButtons(lastRow, iVar, nrCBButtonVals, varInfo(iVar).varOptions, varInfo(iVar).varOptionText, False)
        Case "CheckBoxOther"
            nrCBButtonVals = nrCBButtonVals + 1
            res = SetUpCBButtons(lastRow, iVar, nrCBButtonVals, varInfo(iVar).varOptions, varInfo(iVar).varOptionText, True)
        Case "TextEntry"
            res = SetUpTextEntry(lastRow, iVar, varInfo(iVar).varType, varInfo(iVar).varOptions, varInfo(iVar).varOptionText)
        Case "DateEntry"
            res = SetUpTextEntry(lastRow, iVar, varInfo(iVar).varType, varInfo(iVar).varOptions, varInfo(iVar).varOptionText)
        Case "NumberEntry"
            res = SetUpTextEntry(lastRow, iVar, varInfo(iVar).varType, varInfo(iVar).varOptions, varInfo(iVar).varOptionText)
        End Select
        lastRow = lastRow + 10
    Next iVar
    QuitButton.Top = lastRow
    lastRow = lastRow + 30
    PhraseDisplay.Height = lastRow + 50

    DisplayCorrectedPhrase
    SetUpForm = True
    End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:24:41+00:00Added an answer on June 11, 2026 at 8:24 am
    For iVar = 1 To nrVars     
    
      With Me.Controls("VarFrame" & iVar)        
        .Caption = varInfo(iVar).varName         
        .Top = lastRow         
        .Left = leftMargin         
        .Height = 12         
        .Visible = True 
      End With
    
    Next iVar
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have the following code: switch (publicationType) { case PublicationType.Book: return Session.Query<Publication>() .Where(p
I have a domain (read) and reporting (write) database on the same machine. Currently,
I currently have one project that currently contains multiple packages. These packages make up
At my company we have several pseudo-independent teams, owning several repositories each (but sometimes
I have a case where I'm provided with one UL, and an unknown number
I have two ActiveRecord models of the same class: #1: represents the current committed
Currently have a drop down menu that is activated on a hover (from display:none
Currently have password protection on my main and sub directories, however I'd like to
I currently have a XSLT 2.0 Stylesheet that I am trying to remove empty
I currently have a table of concentrations, which are linked to a table of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.