DHJJ [Hatsune's Journal Japan] blog

Hatsune's Journal Japan blog

目次

Blog 利用状況

ニュース

最新ツイート

運営サイト

Hatsune's Journal Japan
DHJJ

著作など

資格など

OCP
MCP

書庫

日記カテゴリ

わんくま同盟

[VB2005]縦書き

ネタ元:[C++] 縦書き

VB2005でやってみた。

Module Yoko2Tate
    Sub Main(ByVal args() As String)
        Dim dest() As String
        Using sr As New System.IO.StreamReader(args(0), System.Text.Encoding.GetEncoding("Shift_JIS"))
            Dim buf As String = sr.ReadToEnd
            Dim src() As String = Split(buf, vbCrLf)
            Dim maxlength As Integer = 0
            For rowcount As Integer = 0 To src.Length - 1
                If src(rowcount).Length > maxlength Then maxlength = src(rowcount).Length
            Next
            ReDim dest(maxlength)
            For colcount As Integer = 0 To maxlength - 1
                For rowcount As Integer = src.Length - 1 To 0 Step -1
                    If src(rowcount).Length < maxlength Then src(rowcount) = (src(rowcount) & New String(CChar(" "), maxlength)).Substring(0, maxlength)
                    dest(colcount) = dest(colcount) & src(rowcount).Substring(colcount, 1)
                Next
            Next
            sr.Close()
        End Using
        Using sr As New System.IO.StreamWriter(args(1), False, System.Text.Encoding.GetEncoding("Shift_JIS"))
            For rowcount As Integer = 0 To dest.Length - 1
                sr.WriteLine(dest(rowcount))
            Next
            sr.Close()
        End Using
    End Sub
End Module

現状で27行のコードですが、StreamReaderとかStreamWriterのCloseせずUsing-End Usingなどの安全策も除いちゃうと23行になります。

:でFor~Nextを1行にしちゃうような事はあえてしてないですが、単独ループではなく「If src(rowcount).Length < maxlength Then 」で空白補完のループを省略したのは内緒www

投稿日時 : 2008年12月17日 17:27

Feedback

# vb2005-でつながるブログリング 2009/01/05 19:17 blogring.org

vb2005に関するブログをまとめています。

# destockchine 2013/01/09 10:00 http://www.destockchinefr.fr/veste-marque-pas-cher

The actual worst case scenario solution to miss any person needs to be placed proper alongside them all with the knowledge you can憑t|capital t|big t|to|testosterone levels|testosterone|w not|longer|l|r|g|s|h|d|p|T|metric ton|MT|tonne} ask them to.
destockchine http://www.destockchinefr.fr/veste-marque-pas-cher/veste-ed-hardy-pas-cher/

# Sarenzalando 2013/01/11 23:14 http://www.robenuk.eu/

Simply no individual may your rips, along with one who is usually North Korean won‘l help you to hollo.
Sarenzalando http://www.robenuk.eu/

# casquette obey 2013/03/14 5:00 http://www.b44.fr/

Take pleasure in, companionship, prize, you shouldn't unite many people as much as a typical hatred for one. casquette obey http://www.b44.fr/

# code promo zalando 2013/04/06 3:37 http://ruemee.com/

Really enjoy is a established interest for ones everyday life and then the development of that which we appreciate. code promo zalando http://ruemee.com/

# gemo 2013/04/06 23:22 http://ruezee.com/

Fancy is going to be current requirement for daily life in addition to the increase of what you romance. gemo http://ruezee.com/

タイトル
名前
Url
コメント