Perform Life Data Analysis on External Data Source/VBA

From ReliaWiki
Jump to navigation Jump to search
APIWiki.png



Tutorial: Life Data Analysis

Below is the VBA version of the tutorial.

VBA

Sub Main()

  'Declare a new WeibullDataSet object.  
   Dim WDS As New WeibullDataSet
  
  'Add the failure times to the data set. 
   Call WDS.AddFailure(16, 1)
   Call WDS.AddFailure(34, 1)
   Call WDS.AddFailure(53, 1)  
   Call WDS.AddFailure(75, 1)
   Call WDS.AddFailure(93, 1)
  
  'Add the suspensions to the data set. 
   Call WDS.AddSuspension(120, 5)   

  'Use the 2-parameter Weibull distribution and the rank regression on X (RRX) analysis method. 
  'Keep all other analysis settings at default. 
   WDS.AnalysisSettings.Distribution = WeibullSolverDistribution_Weibull
   WDS.AnalysisSettings.Parameters = WeibullSolverNumParameters_MS_2Parameter
   WDS.AnalysisSettings.Analysis = WeibullSolverMethod_RRX
 
  'Analyze the data set. 
   Call WDS.Calculate()

  'Calculate the probability of failure at 226 hrs and display the result. 
   Dim r As Double
   r = WDS.FittedModel.unreliability(226)
   MsgBox("Prob. Fail: " & r)

End Sub