iSAMrx72's 思い付きBlog

今、新しいアカウントではじめました、への投稿となります。https://blog.goo.ne.jp/isamrx72

VB2005ソースを書き込みする方法は

2007-11-29 11:28:21 | パソコン
 今まで、いろいろやってきた結果分かったことは、ブログの書き込みはコードがそのまま書き込めない。 ブログの独特の文字へ変換して、書き込みしないといけない。 ここからは文章の作成のことですが、ブログ用に変換したファイルがある場合は、それを読み込め。 というか、読み込む機能があれば、コピー&ペーストでなくやれる。

畳の大きさの計算 by VB2005Express

2007-11-29 10:27:53 | パソコン
Public Class Form1
    '部屋の大きさから、作る畳一枚一枚部屋の大きさ分作るとき畳の大きさを計算します。<br />
    '適当なモデルを知らないのでクラスを使えばどうなるのか、見よう見まねです。<br />

    Dim a1Tatami As Tatami
    Dim a2Tatami As NiTatami
    Dim a3Tatami As SanTatami
    Dim a4Tatami As YonTatami

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '畳は7つの数字で製作されます<br />
        'VB2005Expressは無料で使えますので、使ってみてください。<br />
        'あまりに巧妙な動きに感動します。<br />

        '以下は2畳から四畳までの部屋の大きさを図ったものを入力したことを、変わりに数字をセットしてます<br />

        Dim Sv1 As Integer() = New Integer() {0, 10, 20, 30, 40, 50, 60}
        Dim Sv2 As Integer() = New Integer() {100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230}
        Dim Sv3 As Integer() = New Integer() {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160}
        Dim Sv4 As Integer() = New Integer() {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190}
        'a1Tatami = New Tatami
        'a1Tatami.AtaiSet(Sv1)

        'a2Tatami = New NiTatami
        'a2Tatami.AtaiSet(Sv2)

        'a3Tatami = New SanTatami
        'a3Tatami.AtaiSet(Sv3)

        '一畳から三畳まではチェックがすんでます<br />

        a4Tatami = New YonTatami
        a4Tatami.AtaiSet(Sv4)

    End Sub
End Class

Public Class Tatami
    Private Atai(6) As Integer

    Public Sub AtaiSet(ByVal Sv() As Integer)
        Dim w As Integer


        For w = 0 To 6
            Atai(w) = Sv(w)
        Next

        Debug.Print("{0} {1} {2} {3} {4} {5} {6}", Atai(0), Atai(1), Atai(2), Atai(3), Atai(4), Atai(5), Atai(6))

    End Sub


End Class

Public Class NiTatami

    Dim aT1 As Tatami
    Dim aT2 As Tatami


    Public Sub AtaiSet(ByVal Sv2() As Integer)
        Dim RSv1(6) As Integer
        Dim RSv2(6) As Integer

        Dim w1 As Integer
        Dim w2 As Integer

        w1 = (Sv2(1) + Sv2(4)) / 2
        w2 = (Sv2(1) + Sv2(4)) - w1
        RSv1(1) = w1
        RSv1(0) = w1 + Sv2(3) - Sv2(4)
        RSv1(2) = w1 + Sv2(5) - Sv2(4)
        RSv1(3) = Sv2(8)
        RSv1(4) = Sv2(9)
        RSv1(5) = Sv2(12)
        RSv1(6) = Sv2(13)

        RSv2(1) = w2
        RSv2(0) = w2 + Sv2(2) - Sv2(1)
        RSv2(2) = w2 + Sv2(0) - Sv2(1)
        RSv2(3) = Sv2(11)
        RSv2(4) = Sv2(10)
        RSv2(5) = Sv2(7)
        RSv2(6) = Sv2(6)

        aT2 = New Tatami
        aT2.AtaiSet(RSv2)
        aT1 = New Tatami
        aT1.AtaiSet(RSv1)


    End Sub

End Class

Public Class SanTatami
    Dim a1T3 As Tatami
    Dim a2T2 As NiTatami

    Public Sub AtaiSet(ByVal Sv3() As Integer)
        Dim RSv3(6) As Integer
        Dim Sv2(13) As Integer

        Dim w1 As Integer
        Dim w2 As Integer
        Dim a2T2 As NiTatami

        w1 = Int(((Sv3(11) + Sv3(15)) / 3) / 5) * 5
        w2 = Sv3(11) - w1
        RSv3(1) = w1
        RSv3(0) = Sv3(10) - Sv3(11) + w1
        RSv3(2) = Sv3(12) - Sv3(11) + w1
        RSv3(3) = Sv3(1)
        RSv3(4) = Sv3(0)
        RSv3(5) = Sv3(6)
        RSv3(6) = Sv3(5)

        a1T3 = New Tatami
        a1T3.AtaiSet(RSv3)

        Sv2(0) = Sv3(2)
        Sv2(1) = Sv3(3)
        Sv2(2) = Sv3(4)
        Sv2(3) = Sv3(7)
        Sv2(4) = Sv3(8)
        Sv2(5) = Sv3(9)
        Sv2(6) = w2
        Sv2(7) = w2
        Sv2(8) = w2
        Sv2(9) = w2
        Sv2(10) = Sv3(13)
        Sv2(11) = Sv3(14)
        Sv2(12) = Sv3(15)
        Sv2(13) = Sv3(16)

        a2T2 = New NiTatami
        a2T2.AtaiSet(Sv2)

    End Sub


End Class
Public Class YonTatami
    Dim a1T4 As Tatami
    Dim a3T3 As SanTatami
    Public Sub AtaiSet(ByVal Sv4() As Integer)
        Dim RSv4(6) As Integer
        Dim Sv3(16) As Integer

        Dim w1 As Integer
        Dim w2 As Integer

        w1 = Int(((Sv4(15) + Sv4(18)) / 4) / 5) * 5
        w2 = Sv4(18) - w1
        RSv4(1) = w1
        RSv4(0) = Sv4(19) - Sv4(18) + w1
        RSv4(2) = Sv4(17) - Sv4(18) + w1
        RSv4(3) = Sv4(12)
        RSv4(4) = Sv4(13)
        RSv4(5) = Sv4(5)
        RSv4(6) = Sv4(6)

        a1T4 = New Tatami
        a1T4.AtaiSet(RSv4)

        Sv3(0) = Sv4(0)
        Sv3(1) = Sv4(1)
        Sv3(2) = Sv4(2)
        Sv3(3) = Sv4(3)
        Sv3(4) = Sv4(4)
        Sv3(5) = Sv4(7)
        Sv3(6) = Sv4(8)
        Sv3(7) = Sv4(9)
        Sv3(8) = Sv4(10)
        Sv3(9) = Sv4(11)
        Sv3(10) = Sv4(14)
        Sv3(11) = Sv4(15)
        Sv3(12) = Sv4(16)
        Sv3(13) = w2
        Sv3(14) = w2
        Sv3(15) = w2
        Sv3(16) = w2

        a3T3 = New SanTatami
        a3T3.AtaiSet(Sv3)


    End Sub

End Class

VB2005Expressのソースをブログ用に変換。By VB2005

2007-11-29 08:50:27 | パソコン
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim line As String

        Dim reader As New System.IO.StreamReader("c:\data\sosu.txt", System.Text.Encoding.Default)
        Dim writer As New System.IO.StreamWriter("c:\data\kekka.txt", False, System.Text.Encoding.Default)
        '"c:\data\sosu.txt"ソースコードをコピーしておく
        '"c:\data\kekka.txt"ブログ用に変換したコードが書かれるファイル

        textbox1.clear()
        Do Until reader.EndOfStream
            line = reader.ReadLine()
            line = line.Replace("&", "&amp;")
            line = line.Replace("<", "&lt;")
            line = line.Replace(">", "&gt;")
            line = line.Replace(" ", "&nbsp;")
            line = line.Replace(vbTab, "&nbsp;&nbsp;&nbsp;&nbsp;")

            TextBox1.AppendText(line & "<br />" & ControlChars.CrLf)
            writer.WriteLine(line & "<br />" & ControlChars.CrLf)
        Loop
        writer.Close()
        reader.Close()

    End Sub
End Class
前回のものからSubStringは必要ないので取りました。

VB2005のソースをブログ用に変換する。By VB2005

2007-11-28 10:57:02 | パソコン
========================================
プロジェクトはWindowsアプリケーションで、TestBox一つとBottonが一つあります。
Buttonをクリックするとプログラムが始まります。
========================================
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim line As String

        Dim reader As New System.IO.StreamReader("c:\data\sosu.txt", System.Text.Encoding.Default)
        Dim writer As New System.IO.StreamWriter("c:\data\kekka.txt", False, System.Text.Encoding.Default)
        '"c:\data\sosu.txt"ソースコードをコピーしておく
        '"c:\data\kekka.txt"ブログ用に変換したコードが書かれるファイル

        textbox1.clear()
        Do Until reader.EndOfStream
            line = reader.ReadLine()
            line = line.Replace("&", "&amp;")
            line = line.Replace("<", "&lt;")
            line = line.Replace(">", "&gt;")
            line = line.Replace(" ", "&nbsp;")
            line = line.Replace(vbTab, "&nbsp;&nbsp;&nbsp;&nbsp;")

            TextBox1.AppendText(line.Substring(0) & "<br />" & ControlChars.CrLf)
            writer.WriteLine(line.Substring(0) & "<br />" & ControlChars.CrLf)
        Loop
        writer.Close()
        reader.Close()

    End Sub
End Class

================================================
自分自身を処理したものです。