C# と VB.NET の質問掲示板

わんくま同盟

ASP.NET、C++/CLI、Java 何でもどうぞ

C# と VB.NET の入門サイト


(過去ログ 18 を表示中)
■7181 / )  Re[12]: VBについて
□投稿者/ まる (8回)-(2007/08/31(Fri) 15:48:53)
No7123 (mあ さん) に返信
>
遅くなりました。
Public Class Form1
Inherits System.Windows.Forms.Form
Dim a(200), d(200) As String
Dim n, c(200) As Integer
Dim ss As String

#Region " Windows フォーム デザイナで生成されたコード "

Public Sub New()
MyBase.New()

' この呼び出しは Windows フォーム デザイナで必要です。
InitializeComponent()

' InitializeComponent() 呼び出しの後に初期化を追加します。

End Sub

' Form は、コンポーネント一覧に後処理を実行するために dispose をオーバーライドします。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

' Windows フォーム デザイナで必要です。
Private components As System.ComponentModel.IContainer

' メモ : 以下のプロシージャは、Windows フォーム デザイナで必要です。
'Windows フォーム デザイナを使って変更してください。
' コード エディタを使って変更しないでください。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents retu As System.Windows.Forms.TextBox
Friend WithEvents startButton As System.Windows.Forms.Button
Friend WithEvents finishButton As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.retu = New System.Windows.Forms.TextBox
Me.startButton = New System.Windows.Forms.Button
Me.finishButton = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(120, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(56, 16)
Me.Label1.TabIndex = 0
Me.Label1.Text = "文字列 :"
'
'retu
'
Me.retu.Location = New System.Drawing.Point(176, 24)
Me.retu.Name = "retu"
Me.retu.Size = New System.Drawing.Size(384, 19)
Me.retu.TabIndex = 1
Me.retu.Text = ""
'
'startButton
'
Me.startButton.Location = New System.Drawing.Point(264, 56)
Me.startButton.Name = "startButton"
Me.startButton.TabIndex = 2
Me.startButton.Text = "実行"
'
'finishButton
'
Me.finishButton.Location = New System.Drawing.Point(376, 56)
Me.finishButton.Name = "finishButton"
Me.finishButton.TabIndex = 3
Me.finishButton.Text = "終了"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
Me.ClientSize = New System.Drawing.Size(744, 381)
Me.Controls.Add(Me.finishButton)
Me.Controls.Add(Me.startButton)
Me.Controls.Add(Me.retu)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub startButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startButton.Click

'textboxに入力した文字列をssにうつして、文字列の長さを返す
ss = retu.Text
n = ss.Length()

'@3文字で区切ったものを配列に格納(文字組)
Dim i As Integer
Do
For i = 0 To n - 3
If i = 0 Then
a(i) = Microsoft.VisualBasic.Left(ss, 3)
Else
a(i) = Mid(ss, i + 1, 3)
End If
Next
Loop While i <= n - 3

Dim j As Integer
Do
For j = 0 To n - 3
If j = 0 Then
d(j) = Microsoft.VisualBasic.Left(ss, 3)
Else
d(j) = Mid(ss, j + 1, 3)
End If
Next
Loop While j <= n - 3

'A同じ順序に並んだ文字組を探す
Dim b As Integer
Do
For i = 0 To n - 3
For j = 0 To n - 3
For b = 0 To n - 3
c(i) = StrComp(a(i), d(j))
If c(b) = 0 Then
c(b) = c(b) + 1
d(j) = "zero"
End If
Next
Next
Next
Loop While i <= n - 3

'B2個以上あるデータを出力
Do
For i = 0 To n - 3
If c(b) >= 1 Then
Print(a(i))
End If
Next
Loop While i <= n - 3

End Sub

'終了ボタンでプログラム終了
Private Sub finishButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles finishButton.Click
End
End Sub

End Class

自分で一応考えて作ってみたのですが動きません。指摘をお願いします。
返信 編集キー/


管理者用

- Child Tree -