I have a working IF-THEN-ELSE, could I request a little help on the messages in the msgbox I have read and read thought they wanted 

ASCII Chr 13 in the help file I saw (Chr(*)) thevalue for ascii 13 which when I use Alt numeric 13 I get the question Mark I am attaching the working code and a few ways I tried the Message to get more in the box. I have learned about the 0 - 5 and the options it gives.

The first code works, not message box like I want with 3 lines. Then next section of code is what I have tried and failed on

Loosing a lot of time if I could get someone in the know to help. Tried from 12:18am to 3:47am finally got the IF then working

but could never get the message Box.

Private Sub SeletRoutine()
' 050419 - This is working need to know how to enter multi-Line Message____________________________________RJB
Dim Message, Title, Default, ValSel

ShowStatus "              "
Title = "Enter Selection to RUN"    ' Set title. 060419 Modified_______RJB
Message = "Enter a value between 1 and 3"    ' Set prompt.
'Message = "Selection 2 Set View Attributes "    ' Set prompt.
Default = "1"    ' Set default.
ValSel = InputBox(Message, Title, , , , "DEMO.HLP", 10)
' Display message, title, and default value.

If ValSel = 1 Then
      'MsgBox "User pressed Yes!"
      ShowStatus " 1 was selected"
   ElseIf ValSel = 2 Then
      'MsgBox "User Pressed No!"
      CadInputQueue.SendKeyin "Macro SetDesignFileView"
      ShowStatus "View Set w=985 H=723"
    ElseIf ValSel = 3 Then
      'MsgBox "User Pressed No!"
            ShowStatus "3 was selected"
      'MsgBox "User Pressed Cancel!"
      ShowStatus "Cancel was selected"
   End If

End Sub

Private Sub Selections()
' 060519 - Trying again
Dim Message, Title, Default, ValSel
    Title = "InputBox Select Feature:    'Set title."
    'Message = "Enter 1 for yellow Magenta ? Enter 2 for green magenta.? Enter 3 for Cyan Magenta?"
    'Message = "Enter a value between 1 and 3?", 2 "Second row of questions"    ' Set prompt. this failed
    Message = "Enter 1 for yellow Magenta ?',(Chr(?)), "Enter 2 for green magenta.?",(chr(?)), "Enter 3 for Cyan Magenta?"

Above code is another working macro. Did not want to mess it up 
so started another with different name. Trying to figure out a multi-line message box

  • Hi Richard,

    I appreciate VBA programming is something you are only just trying to get to grips with, I'm far from being a VBA expert though I too have received plenty of help in the past from Jon and Jan who have helped me reach a level of competence where I can now tackle many tasks on my own. I will assist you where I can however it's a bit hard to understand what your actual aim is. It would be beneficial if you explain the goal of the code and what the user is expected to experience in order to help you reach a solution quicker.

    The sketch is fine. Something I have done previously when starting on a complex program I wrote was to draw out a flow-chart diagram showing the user interface and what happened whenever a user pressed a certain button or entered a certain value. It can help as a guide for how you need to lay out your code by breaking it down into individual tasks.

    As for the code samples, you have provided 2 procedures called SeletRoutine (spelling mistake?) and Selections yet they do not appear to be related as one is not called from another which is what I would have initially expected i.e. it sounds like you want a dialog box to appear (called a userform), the user is then required to enter a number and then something to happen afterwards. Please be clear if that is or not the intention.

     As for the code you have provided, some observations:

    • Variable declarations:
      I VBA when declaring variables (a storage location paired with a name and used to represent a particular value) you should also define the variable's type (if you don't I believe the variable gets assigned by default as a Variant). The current syntax in your code samples (i.e. Dim Var1, Var2. Var3 etc...) is used in VBscript not VBA.

      e.g. If you have a variable which will store text

    Dim Variable_One As String

    If you have a variable which will store a decimal number

    Dim Variable_Two As Long

    If you have a variable which will store a whole number number

    Dim Variable_Three As Integer


    • Multi-line text
      One of your comments mentions multi-line text, in order to do that in VBA you need to use the command vbCrLf
      If the intentional use for multi-line text was to create the userform message (as per your sketch), a better method is using the Userform objects such as individual labels.

  • Thank You #1 I got the code from Goggle search and attempted to modify for what I was trying to learn. the code I will stick with the one that at least works

    SelectRoutine I messed up on the word Select yes. Ok working from that

    I am going to post 2 pictures of the MsgBox close to what I want the achieve.

    the drawing was to show what I was trying to get the Message box to do and could not.

    Where it says Enter a value is where I was hoping to have the

    Text example in the Sketch 

    Color Green-Magenta                "button" [1]

    Color Cyan-Megenta     "second button" [2]

    Color Blue-Red         "then a 3rd button" [3]

     and if possible a Cancel Button       [Cancel]

    looking above I do not want the text in " " just the color selections

    and the Cancel button w/no explanation text

    Is another example w/Cancel I was hoping to have 4 total selections

    "Button1" [1]

    "Button2"[2]  etc with the Cancel at the bottom. Do not really care for the long open box to put numbers in but liveable if I could get the information above the long open box for the 1, 2 or 3 plus the Cancel. Anything like that

    is fine. the two macro's were to show the different Msgbox's

    Lets focus on this and will work out the rest because it does work Example

    i can put a 1, 2 or 3 and it will go to them. So if you know how to put the information on the screen (again this is not going to be used as it is )

    trying to learn and it proves it works via the ShowStatus

    I was looking at a Menu command but do not know enough to figure out how it will do a similar task. Again @ 74 June 12th I do not have the time to read a lot of books. I used Jon Summers suggestion and goggle it . It seems I cannot ask the question properly to find the answer on this part the  buttons and Text information.

    Version: MicroStation V8i SS 10

    RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus

  • Again @ 74 June 12th I do not have the time to read a lot of books.

    Which means you are deserved to fail every time :-(

    And it's nothing that you can be proud of.

    Cumulated sum of time required to solve issues and errors done because there is no strong knowledge foundation (which can be acquired reading just by one or two books at max) is always several times bigger than time required to read this book.



Reply Children
No Data