
水曜日, 10月 15, 2025
Visual Studio Basic_44
同一階層内のファイル名入れ替え Vol.2

火曜日, 9月 30, 2025
Visual Studio Basic_43
同一階層内のファイル名入れ替え
土曜日, 12月 07, 2024
Visual Studio Basic_42
簡易エディター作成は思ったよりも簡単でした
' File>New でTextBox1をクリア
End Sub
-----------------
Private Sub OpenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OpenToolStripMenuItem.Click
Dim openFileDialog As New OpenFileDialog()
openFileDialog.Filter = "テキストファイル (*.txt)|*.txt|すべてのファイル (*.*)|*.*"
If openFileDialog.ShowDialog() = DialogResult.OK Then
TextBox1.Text = System.IO.File.ReadAllText(openFileDialog.FileName)
End If
End Sub
-----------------
Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click
Dim saveFileDialog As New SaveFileDialog()
saveFileDialog.Filter = "テキストファイル (*.txt)|*.txt|すべてのファイル (*.*)|*.*"
If saveFileDialog.ShowDialog() = DialogResult.OK Then
System.IO.File.WriteAllText(saveFileDialog.FileName, TextBox1.Text)
End If
End Sub
-----------------
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
' File>Exit でプログラム終了
End Sub
-----------------
Private Sub CutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CutToolStripMenuItem.Click
TextBox1.Cut()
End Sub
-----------------
Private Sub CopyToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CopyToolStripMenuItem.Click
TextBox1.Copy()
End Sub
-----------------
Private Sub PasteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles PasteToolStripMenuItem.Click
TextBox1.Paste()
End Sub
End Class
土曜日, 11月 16, 2024
Visual Studio Basic_41
元金と利率から元利合計が2倍になるのは何年後?
Public Class Form1
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles Button1.Click
' 入力値を取得
Dim principal As Double = Convert.ToDouble(TextBox1.Text)
Dim rate As Double = Convert.ToDouble(TextBox2.Text) / 100
' 経過年数と元利合計を計算
Dim years As Integer = 0
Dim amount As Double = principal
While amount <= 2 * principal
amount += amount * rate
years += 1
End While
' 結果を表示
Label5.Text = years.ToString()
Label7.Text = amount.ToString("F2")
End Sub
Private Sub Button2_Click(sender As Object,
e As EventArgs) Handles Button2.Click
TextBox1.ResetText()
TextBox2.ResetText()
Label5.ResetText()
Label7.ResetText()
End Sub
Private Sub Button3_Click(sender As Object,
e As EventArgs) Handles Button3.Click
End
End Sub
End Class
金曜日, 11月 01, 2024
Visual Studio Basic_40
西暦に対する十干十二支を計算
実際のプログラム完成日は2024年8月17日です。
水曜日, 10月 16, 2024
Visual Studio Basic_39
正N角形の内角を割り出し偶数か奇数かを判別
------------------
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim n As Integer
Dim angle As Double
' TextBox1に入力された値を整数に変換
If Integer.TryParse(TextBox1.Text, n) AndAlso n >= 3 Then
' 正多角形の内角の角度を計算
angle = ((n - 2) * 180) / n
' 角度が偶数かどうかを確認
If angle Mod 2 = 0 Then
' 偶数の場合
Label4.ForeColor = Color.Empty
Label4.Text = angle.ToString("F0") & " 度"
Label6.ForeColor = Color.Empty
Label6.Text = "偶数"
Else
' 奇数の場合、小数点以下4桁まで表示
Label4.ForeColor = Color.Blue
Label4.Text = angle.ToString("F10") & " 度"
Label6.ForeColor = Color.Blue
Label6.Text = "奇数"
End If
Else
' 有効な値が入力されていない場合
Label4.ForeColor = Color.Red
Label4.Text = "正多角形は3以上の整数です"
Label6.ForeColor = Color.Red
Label6.Text = "計算できません"
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.ResetText()
Label4.ResetText()
Label4.ForeColor = Color.Empty
Label6.ResetText()
Label6.ForeColor = Color.Empty
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
End
End Sub
End Class
------------------

































