------------------
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim opacity As Double
Dim layers As Integer
Dim currentTransparency As Double
' TextBox1から不透明度を取得
If Double.TryParse(TextBox1.Text, opacity) AndAlso opacity > 0 AndAlso opacity <= 100 Then
' 初期化
layers = 0
currentTransparency = 1.0
' 不透明度N%を透明度に変換
Dim transparency = 1 - (opacity / 100)
' 99%以上不透明になるまでの層の計算
Do While currentTransparency > 0.01
currentTransparency *= transparency
layers += 1
Loop
' 結果をLabel4に表示
Label4.Text = layers.ToString()
Else
' 無効な入力の場合のエラーメッセージ
Label7.Text = "0より大きく100以下の数値を入力してください"
End If
End Sub
------------------Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.ResetText()
Label4.ResetText()
Label7.ResetText()
End Sub
------------------Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
End
End Sub
End Class
------------------