×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

HOUSE.EBM...

HOUSE.EBM...

HOUSE.EBM...

(OP)
Hello.

Simple question???

I will assume that everyone is familiar with the HOUSE macro provided by Attachmate to showcase some of its functionality. It collects some input from the user, then is followed by a msgbox message: Congratulations! You just bought a ..., in Anywhere, USA.

If I wanted to utilize the data selected by the user, from within Main()instead of within the function, how could I do that? Could I even use this same data in other functions?

CODE

Declare Function DisplayChoice(szCity$, iStyle%, iBedBath%, iColor%, szLocale$, _
                               iShutters%, iFence%, iGarage%) As String

'--------------------------------------------------------------------------------
' Routine:      Main
'
' Description:  Defines and runs a dialog that enables the user to select specific
'               options in the design of there new house.
'
'               It uses checkboxes, text strings, option groups, drop list boxes,
'               drop combo boxes, and push buttons.  It then uses this information
'               to display the user's selections.
'
'--------------------------------------------------------------------------------
Sub Main
Dim szCity$, szLocation$
Dim iStyle%, iBedBath%, iColor%, iShutters%, iFence%, iGarage%
Dim iDone%
Dim szHouse as String

        Begin Dialog dlgHouseSample 0, 1, 285, 193, "House Designer"
           ButtonGroup .ButtonPressed
           OkButton  225, 10, 50, 14
           CancelButton  225, 30, 50, 14
           PushButton  225, 50, 50, 14, "&Reset", .btnReset
           Text  10, 28, 20, 10, "City:"
           TextBox  30, 25, 79, 14, .tbxCity
           OptionGroup .ogStyle
              OptionButton  15, 130, 73, 10, "Rambler", .btnRambler
              OptionButton  15, 140, 73, 10, "Two Story", .btn2Story
              OptionButton  15, 150, 73, 10, "Split Level", .btnSplitLevel
              OptionButton  15, 160, 73, 10, "Three Story", .btn3Story
           GroupBox  10, 120, 95, 55, "Style"
           CheckBox  15, 60, 91, 12, "Shutters", .cbxShutters
           CheckBox  15, 75, 91, 12, "Fence", .cbxFence
           CheckBox  15, 90, 91, 12, "Garage", .cbxGarage
           Text  145, 75, 77, 8, "Color:"
           DropListBox  145, 90, 81, 30, "Blue"+chr$(9)+"Brown"+chr$(9)+"Grey"+chr$(9)+"Pink Polka

Dots"+chr$(9)+"White"+chr$(9)+"Yellow", .dlbColor
           Text  145, 40, 66, 8, "Location"
           DropComboBox  145, 55, 70, 30, "inner city"+chr$(9)+"rural"+chr$(9)+"suburban",

.dcbLocation
           Text  12, 5, 202, 9, "Pick the characteristics of your new house."
           GroupBox  145, 120, 105, 55, "Bedrooms/Bathrooms"
           OptionGroup .ogBedBath
              OptionButton  150, 130, 85, 10, "2 Bedroom, 1 Bath", .btn2bd1bth
              OptionButton  150, 140, 85, 10, "2 Bedroom, 2 Bath", .btn2bd2bth
              OptionButton  150, 150, 85, 10, "3 Bedroom, 1 Bath", .btn3bd1bth
              OptionButton  150, 160, 85, 10, "3 Bedroom, 2 Bath", .btn3bd2bth
        End Dialog

    iDone = FALSE

    While (iDone = FALSE)    
        Dim dMain as dlgHouseSample

        nRet = Dialog(dMain)
        
        Select Case nRet
            Case -1                       ' -1 is returned if the user chose OK
                iDone = TRUE
                szCity = dMain.tbxCity
                iStyle = dMain.ogStyle
                iBedBath = dMain.ogBedBath
                iColor = dMain.dlbColor
                szLocation = dMain.dcbLocation
                iShutters = dMain.cbxShutters
                iFence = dMain.cbxFence
                iGarage = dMain.cbxGarage
                szHouse = DisplayChoice(szCity, iStyle, iBedBath, iColor, szLocation, _
                                        iShutters, iFence, iGarage)
                msgbox (szHouse)
                
            Case 0                        ' 0 is returned if the user chose Cancel
                iDone = TRUE
                
            Case 1                        ' 1 is returned if the user chose Reset
                dMain.tbxCity = ""
                dMain.ogStyle = 0
                dMain.ogBedBath = 0
                dMain.dlbColor = 0
                dMain.dcbLocation = ""
                dMain.cbxShutters = 0
                dMain.cbxFence = 0
                dMain.cbxGarage = 0
            Case Else
                msgbox "Some undefined button pressed " + str(dMain.ButtonPressed)
                
        End Select
    Wend

End Sub


'--------------------------------------------------------------------------------
' Function:     DisplayChoice(szCity$, iStyle%, iBedBath%, iColor%, szLocale$
'                             iShutters%, iFence%, iGarage%) as String
'
' Parameters:   szCity -    String containing the selected city.
'               iStyle -    Integer indicating Style selection.
'               iBedBath -  Integer designating bedroom and bathroom selections.
'               iColor -    Integer specifying Color choice.
'               iLocale -   String containing the locale selected.
'               iShutters - Boolean that indicates yes/no for shutters.
'               iFence -    Boolean that indicates yes/no for fence.
'               iGarage -   Boolean that indicates yes/no for garage.
'
' Description:  This function returns a string containing a description of
'               the house characteristics that were selected.
'
'--------------------------------------------------------------------------------
Function DisplayChoice(szCity$, iStyle%, iBedBath%, iColor%, szLocale$, iShutters%, _
                       iFence%, iGarage%) As String
Dim szStyle$, szBedBath$, szColor$, szShutters$, szFence$, szGarage$
Dim szResult$

    If (Trim(szCity) = "") Then
        szCity = "Anywhere, USA"
    End If
    
    Select Case iStyle
    Case 0
        szStyle = "rambler"
    Case 1
        szStyle = "two story house"
    Case 2
        szStyle = "split level house"
    Case 3
        szStyle = "three story house"
    End Select

    Select Case iBedBath
    Case 0
        szBedBath = "two bedroom, one bathroom"
    Case 1
        szBedBath = "two bedroom, two bathroom"
    Case 2
        szBedBath = "three bedroom, one bathroom"
    Case 3
        szBedBath = "three bedroom, two bathroom"
    End Select

    Select Case iColor
    Case 0
        szColor = "blue"
    Case 1
        szColor = "brown"
    Case 2
        szColor = "grey"
    Case 3
        szColor = "pink polka dot"
    Case 4
        szColor = "white"
    Case 5
        szColor = "yellow"
    End Select

    Select Case iShutters
    Case 0
        szShutters = "out "
    Case 1
        szShutters = " "
    End Select

    Select Case iFence
    Case 0
        szFence = "an unfenced, "
    Case 1
        szFence = "a fenced, "
    End Select

    Select Case iGarage
    Case 0
        szGarage = "out "
    Case 1
        szGarage = " "
    End Select
    
    szResult = "Congratulations, you have selected " + szFence + szBedBath + ", " + _
               szColor + ", " + szStyle + " with" + szShutters + "shutters" + _
               " and with" + szGarage + "a garage in a " + szLocale + " community in " + _
               szCity + "."

    DisplayChoice = szResult
End Function

RE: HOUSE.EBM...

tedb13, if you do a search in this forum for DLG, you will find some good examples for dialog boxes

RE: HOUSE.EBM...

(OP)
Thank you vzachin. I did look throughout the forum, but I could not find any clear examples of what I was trying to achieve.

Within Main() after Wend but before End Sub, I entered:

CODE

...Wend
    Colour=dMain.dlbColor

    If Colour=0 then

        Colour="Blue"

    Elseif Colour=1 then

        Colour="Brown"

    Elseif Colour=2 then

        Colour="Grey"

    Elseif Colour=3 then

        Colour="Pink Polka Dots"

    Elseif Colour=4 then

        Colour="White"

    Elseif Colour=5 then

        Colour="Yellow"

    End if

    City=dMain.tbxCity

    If City ="" then

        City="Ottawa"

    End if

    If dMain.cbxFence<>0 then

        Fence="No"

    Else

        Fence="Yes"

    End if
End Sub

This is the only way I could get the values from the Dialog Box with my current knowledge base. I do not know how to get the values from the DisplayChoice() function. Is there a way to do this?  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close