1 / 6

Introduction to MIS

Introduction to MIS. Appendix 12 Visual Basic. Programming Logic Computations Variables Internal functions Conditions Loops Input Output. Appendix: Visual Basic. Math functions Abs Absolute value Atn Arc Tangent Cos Cosine Exp Exponential Fix Returns integer portion

Télécharger la présentation

Introduction to MIS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to MIS Appendix 12 Visual Basic

  2. Programming Logic Computations Variables Internal functions Conditions Loops Input Output Appendix: Visual Basic Math functions Abs Absolute value Atn Arc Tangent Cos Cosine Exp Exponential Fix Returns integer portion Int Converts to integer Log Logarithm Rnd Random number Sgn Signum (-1, 0, 1) Sin Sine Sqr Square root Tan Tangent String functions StrComp Compare two strings LCase, UCase Convert to lowercase or uppercase Len Find length of a string Format Format a string InStr, Left, LTrim Mid, Right, RTrim, Trim Manipulate strings.

  3. VB: Conditions If (condition) Then statements if true Else statements if false End If Select Case Customer Case Customer = ‘Corporate’ Discount = 0.05 Case Customer = ‘Government’ Discount = 0.10 Case Else Discount = 0.01 End Select If (Sales > 1000) Then Bonus = 100 Else Bonus = 0 End If

  4. VB: Loops total = 0 For month = 1 To 12 total = total + SalesForMonth(month) Next month month = 1 sales = 0 Do Until (sales > 100000) sales = sales + SalesForMonth(month) month = month + 1 Loop

  5. VB: Input and Output Could use: InputBox, MsgBox, and Printer object. Generally just use data in the application. In this example, the form collects the data and displays the result.

  6. Sub Macro1() ' Keyboard Shortcut: Ctrl+Shift+U For Each c In Selection c.Value = PCase(c.Value) Next c End Sub VBA: Excel Example Function PCase(txt) ' Convert a text value to proper case Dim i As Integer txt = LCase(txt) Mid(txt, 1, 1) = UCase(Mid(txt, 1, 1)) i = 2 Do While (i > 0) And (i < Len(txt)) i = InStr(i, txt, " ") If (i > 0) And (i < Len(txt)) Then Mid(txt, i + 1, 1) = UCase(Mid(txt, i + 1, 1)) i = i + 1 End If Loop PCase = txt End Function

More Related