(1) x = 5 (2) x = InputBox("数字を入力してください") |
Sub prog() Dim x As Integer, y As Integer x = Sheet1.Cells(1, 1).Value MsgBox "(1, 1)の値は" & x y = Sheet1.Cells(2, 1).Value MsgBox "(2, 1)の値は" & y Sheet1.Cells(1, 2).Value = x + y End Sub |
Sub prog() Dim x As Integer, y As Integer With Sheet1 x = .Cells(1, 1).Value MsgBox "(1, 1)の値は" & x y = .Cells(2, 1).Value MsgBox "(2, 1)の値は" & y .Cells(1, 2).Value = x + y End With End Sub |
Sub prog() datafunc -3.14, 3.14, 60 End Sub Sub datafunc(x1 As Double, x2 As Double, n As Integer) Dim i As Integer Dim x As Double, y As Double, dx As Double dx = (x2 - x1) / n With Sheet1 For i = 0 To n x = x1 + dx * i y = Sin(x) .Cells(i + 1, 1).Value = x .Cells(i + 1, 2).Value = y Next i End With End Sub |