Difference between revisions of "ALTADataSet.Question"

From ReliaWiki
Jump to navigation Jump to search
 
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:APIClass|ALTAEvents Class|ALTAEvents}}
+
{{Template:API}}{{Template:APIBreadcrumb|.[[ALTADataSet Class|ALTADataSet]]}}
{{Template:WeibullEvents.Question.Cmt}}
+
{{Template:InProgress}}
  
== Syntax ==
+
<onlyinclude>Occurs when an answer to a question is required. Displays a message box with yes and no options.</onlyinclude>  
<ul><li>Question(
 
sender
 
{{APIPrefix|As}}
 
[[ALTADataSet Class|ALTADataSet]],
 
sMsg
 
{{APIPrefix|As String}}
 
,
 
Buttons
 
{{APIPrefix|As}}
 
MsgBoxStyle ,
 
Answer
 
{{APIPrefix|As}}
 
MsgBoxResult )
 
</li></ul>
 
  
Parameters
 
:''sender'': An [[ALTADataSet Class|ALTADataSet]] object.
 
  
:''sMsg'': The main display label.
+
{{Template:API_EventsNote}}
 
 
:''Buttons'': The MsgBoxStyle that determines the number and display of the buttons. See [http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.msgboxstyle.aspx MsgBoxStyle] for additional details.
 
 
 
:''Answer'': The MsgBoxResult that is returned by the prompt. See [http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.msgboxresult.aspx MsgBoxResult] for additional details.
 
 
 
== Usage Example ==
 
{{APIComment|'Overrides requested. Create a new class and inherit ALTAEvents. Then set the dataset's Events.}}
 
  Private Class myEvents
 
      Inherits ALTAEvents
 
      Public Overrides Sub Question(sender As ALTADataSet, sMsg As String, Buttons As MsgBoxStyle, ByRef Answer As MsgBoxResult)
 
          MyBase.Question(sender, sMsg, Buttons, Answer)
 
            {{APIComment|'<Add additional code here.>}}
 
      End SubEnd Class
 
 
 
{{APIComment|'Set the new events class.}}
 
  ADS.Events = New myEvents
 
 
 
{{APIComment|'Initialize the MsgBoxStyle and MsgBoxResult variables.}}
 
  Dim MsgBoxStyle1 = New MsgBoxStyle.YesNoCancel
 
  Dim Answer = New MsgBoxResult
 
 
 
{{APIComment|'Ask a question. Result will be updated in Answer.}}
 
  ADS.Events.Question(ADS, "Continue?", MsgBoxStyle1, Answer)
 
<!--
 
  
 +
== Syntax ==
 +
'''_Question'''(''msg'', ''Buttons'', {{APIPrefix|ByRef}} ''Answer'')
  
 +
===Parameters===
 +
''sMsg''
 +
:Required. String. The message to display.
  
 +
''Buttons''
 +
:Required. The buttons to display when calling Visual Basic's MsgBox function. Can be any MsgBoxStyle constant (see [https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.msgboxstyle.aspx Microsoft's reference documentation for this enum]).
  
 +
''Answer''
 +
:Required. Indicates which button was pressed on a message box returned by Visual Basic's MsgBox function. Can be any MsgBoxResult constant (see [https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.msgboxresult.aspx Microsoft's reference documentation for this enum]).
  
 +
<!--== Example ==
 +
The following example provides a simple demonstration on how to customize the event procedure.
 +
'''VBA'''
 +
 +
{{APIComment|'Specify a variable to handle the event.}}
 +
  {{APIPrefix|Private WithEvents}} ads {{APIPrefix|As}} ALTADataSet
 +
 +
{{APIComment|'----------------------------}}
 +
  {{APIPrefix|Sub}} Main()
 +
  {{APIComment|'Associate the event variable with an object.}}
 +
    {{APIPrefix|Set}} ads = {{APIPrefix|New}} ALTADataSet
 +
 +
  {{APIComment|'Set the application to use your event procedure.}}
 +
    ads.UseEvents = True
 +
 +
  {{APIComment|'Define two stress types.}}
 +
    {{APIPrefix|Call}} ads.AddStressDefinition({{APIString|"Temperature"}}, , 300)
 +
    {{APIPrefix|Call}} ads.AddStressDefinition({{APIString|"Humidity"}}, , 0.3)
 +
 +
  {{APIComment|'Select to use the Temperature-Humidity model with a Weibull distribution.}}
 +
    ads.AnalysisSettings.ModelType = ALTASolverModel_TempHumidity
 +
    ads.AnalysisSettings.Distribution = ALTASolverDistribution_Weibull
 +
 +
  {{APIComment|'Trigger the event by analyzing an incomplete data set.}}
 +
    {{APIPrefix|Call}} ads.AddFailure_3(248, 1, 406, 0.5)
 +
    {{APIPrefix|Call}} ads.AddFailure_3(456, 1, 416, 0.7)
 +
    {{APIPrefix|Call}} ads.AddFailure_3(528, 1, 426, 0.9)
 +
 +
    ads.Calculate
 +
    Msgbox({{APIString|"End"}})
 +
  {{APIPrefix|End Sub}}
 +
 +
{{APIComment|'----------------------------}}
 +
  {{APIPrefix|Private Sub}} ads_Question({{APIPrefix|ByVal}} ''msg'' {{APIPrefix|As String}}, _
 +
                          {{APIPrefix|ByVal}} ''Buttons'' {{APIPrefix|As Microsoft_VisualBasic.MsgBoxStyle}}, _
 +
                          ''Answer'' {{APIPrefix|As Microsoft_VisualBasic.MsgBoxResult}})
 +
  {{APIComment|'<Add code here to handle the event.>}}
 +
    {{APIPrefix|Call}} MsgBox (msg, vbYesNoCancel)
 +
  {{APIPrefix|End Sub}}
  
{{APIComment|Declare the ALTAEvents.}}<br>
+
'''VB.NET'''
{{APIComment|Declare the ALTADataSet.}}<br>
+
{{APIComment|Note: The ALTADataSet constructor already creates a new ALTAEvents, which could be used in place of AEvents in the example below.}}<br>
+
{{APIComment|'Specify a variable to handle the event.}}
{{APIComment|Select a message box style. See [http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.msgboxstyle.aspx MsgBoxStyle] for additional details.}}<br>
+
  {{APIPrefix|Private WithEvents}} ads {{APIPrefix|As}} ALTADataSet
{{APIComment|Declare a result variable. See [http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.msgboxresult.aspx MsgBoxResult] for additional details.}}
+
        Dim AEvents as New ALTAEvents
+
{{APIComment|'----------------------------}}
        Dim ADS as New ALTADataSet
+
  {{APIPrefix|Sub}} Main()
        Dim MsgBoxStyle1 as MsgBoxStyle = MsgBoxStyle.OkCancel
+
  {{APIComment|'Associate the event variable with an object.}}
        Dim MsgBoxResult1 as MsgBoxResult
+
    ads = {{APIPrefix|New}} ALTADataSet
 
+
{{APIComment|Prompts user with "Question1" and returns result in MsgBoxResult1.}}
+
  {{APIComment|'Set the application to use your event procedure.}}
        AEvents.Question(ADS, "Question1", MsgBoxStyle1, MsgBoxResult1)
+
    ads.UseEvents = True
 +
 +
  {{APIComment|'Define two stress types.}}
 +
    ads.AddStressDefinition({{APIString|"Temperature"}}, , 300)
 +
    ads.AddStressDefinition({{APIString|"Humidity"}}, , 0.3)
 +
 +
  {{APIComment|'Select to use the Temperature-Humidity model with a Weibull distribution.}}
 +
    ads.AnalysisSettings.ModelType = ALTASolverModel.TempHumidity
 +
    ads.AnalysisSettings.Distribution = ALTASolverDistribution.Weibull
 +
 +
  {{APIComment|'Trigger the event by analyzing an incomplete data set.}}
 +
    ads.AddFailure(248, 1, 406, 0.5)
 +
    ads.AddFailure(456, 1, 416, 0.7)
 +
    ads.AddFailure(528, 1, 426, 0.9)
 +
 +
    ads.Calculate
 +
    Msgbox({{APIString|"End"}})
 +
  {{APIPrefix|End Sub}}
 +
 +
{{APIComment|'----------------------------}}
 +
  {{APIPrefix|Private Sub}} ads_Question(''msg'' {{APIPrefix|As String}}, ''Buttons'' {{APIPrefix|As MsgBoxStyle}}, _
 +
                          {{APIPrefix|ByRef}} ''Answer'' {{APIPrefix|As MsgBoxResult}}) {{APIPrefix|Handles}} ads.Question
 +
  {{APIComment|'<Add code here to handle the event.>}}
 +
    MsgBox (msg, vbYesNoCancel)
 +
  {{APIPrefix|End Sub}}
 
-->
 
-->

Latest revision as of 00:01, 7 September 2016

APIWiki.png


Member of: SynthesisAPI.ALTADataSet

DRAFT GRAY.png

WORK IN PROGRESS
ALTADataSet.Question

DRAFT GRAY.png

Occurs when an answer to a question is required. Displays a message box with yes and no options.


Remarks: To hide the messages or write your own code for the event procedure, set the UseEvents property of the object to True. The event is raised by the class methods.

Syntax

_Question(msg, Buttons, ByRef Answer)

Parameters

sMsg

Required. String. The message to display.

Buttons

Required. The buttons to display when calling Visual Basic's MsgBox function. Can be any MsgBoxStyle constant (see Microsoft's reference documentation for this enum).

Answer

Required. Indicates which button was pressed on a message box returned by Visual Basic's MsgBox function. Can be any MsgBoxResult constant (see Microsoft's reference documentation for this enum).