• 締切済み

VB  FOR~NEXTについて

下記の変数の宣言で、For w As Integer = 1 To 100 のWにチェックが付、デバックできません、考えられる点はどんな事があるのでしょうか? ご教授お願いします。 ' Button4のClickイベントを処理します。 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click ' LineData用の変数です。 Dim cadLineData As New zwDrawCAD.LineData ' 線分の始点と終点を参照します。 Dim cadStartPoint As zwDrawCAD.DPoint = cadLineData.Start Dim cadEndPoint As zwDrawCAD.DPoint = cadLineData.End 'とりあえず線のセンターポイントは(100,100)にしてます。 Const X As Integer = 0 'cadStartPoint.x = 100 Const y As Integer = 0 'cadStartPoint.x = 100 Dim sr As System.IO.StreamReader = Nothing Try Dim file As String = TextBox1.Text 'SRとは New System.IO.StreamReaderの略 sr = New System.IO.StreamReader(file, System.Text.Encoding.GetEncoding("shift_jis")) Dim ansx As Double '計算された、xの座標 Dim ansy As Double '計算された、yの座標 Dim doc As String 'fileの1行 Dim x1 As String '1列目(X) Dim y2 As String '2列目(y)、 Dim x3 As String '3列目(X1)、 Dim y4 As String '4列目(y2) Dim angle As String '5列目(角度)、 Dim spare As String '6列目(予備)、 Dim item() As String ' Dim i As Integer '1行ずつテキストを読み取る doc = sr.ReadLine '1行読む Do Until IsNothing(doc) i += 1 item = doc.Split(",") 'カンマで区切る x1 = item(0) y2 = item(1) x3 = item(2) y4 = item(3) angle = item(4) spare = item(5) f2.data(x1, y2, x3, y4, angle, spare) f2.int(i) TextBox2.Text &= item(0) & " " & item(1) & " " & item(2) & " " & item(4) & " " & item(5) & " " & vbNewLine doc = sr.ReadLine '次の1行を読む Loop f2.println() Catch ex As Exception MessageBox.Show(ex.Message, "read") Finally If sr IsNot Nothing Then sr.Close() sr.Dispose() End If Dim len As Integer 'TextBox1に入力された線の長さ Dim angle As Double 'TextBox2に入力された角度 単位は度 Dim ansx As Double '計算された、xの座標 Dim ansy As Double '計算された、yの座標 '変数の宣言 Dim w As Integer Dim i As Integer '初期化 w = 0 i = 0 For w As Integer = 1 To 100 len = CDbl("x1" / 2) angle = CDbl(angle + 90) ansx = X + len * (Math.Cos(angle / 180 * Math.PI)) '終点のx座標 ansy = y + len * (Math.Sin(angle / 180 * Math.PI)) '終点のy座標 cadStartPoint.x = ansx * -1 cadStartPoint.y = ansy * -1 cadEndPoint.x = ansx cadEndPoint.y = ansy w = w + 1 Next End Try

みんなの回答

回答No.3

こんにちは お久しぶりです。 だいぶ時間が過ぎてしまいましたので、「時すでに遅し」といった感じでしょうか。 zwDrawCADがどうしてもわかりませんので、かなり無責任な回答です。 少し、修正しました。 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim f2 As New Form2 Dim ar As New List(Of String) '1列目(X)をコレクションにする Dim cadLineData As New zwDrawCAD.LineData ' 線分の始点と終点を参照します。 Dim cadStartPoint As zwDrawCAD.DPoint = cadLineData.Start Dim cadEndPoint As zwDrawCAD.DPoint = cadLineData.End 'とりあえず線のセンターポイントは(100,100)にしてます。 Const X As Integer = 0 'cadStartPoint.x = 100 Const y As Integer = 0 'cadStartPoint.x = 100 TextBox2.Text = "" Dim sr As System.IO.StreamReader = Nothing ' Try Dim file As String = TextBox1.Text 'SRとは New System.IO.StreamReaderの略 sr = New System.IO.StreamReader(file, System.Text.Encoding.GetEncoding("shift_jis")) Dim doc As String 'fileの1行 Dim item() As String '配列にする Dim x1 As String '1列目(X) Dim y2 As String '2列目(y) Dim x3 As String '3列目(X1) Dim y4 As String '4列目(y2) Dim angle As String '5列目(角度) Dim spare As String '6列目(予備) Dim i As Integer 'dataで2次元配列にするためのカウンター '1行ずつテキストを読み取る doc = sr.ReadLine '1行読む Do Until IsNothing(doc) 'ここを変更してます item = doc.Split(",") 'カンマで区切る x1 = item(0) y2 = item(1) x3 = item(2) y4 = item(3) angle = item(4) spare = item(5) f2.int(i) 'Class Form2値を渡す f2.data(x1, y2, x3, y4, angle, spare) 'Class Form2 dataに値を渡す TextBox2.Text &= item(0) & " " & item(1) & " " & item(2) & " " & item(4) & " " & item(5) & " " & vbNewLine doc = sr.ReadLine '次の1行を読む i += 1 'ここを通るたびに1を足す ar.Add(x1) '1列目(X)をコレクションにAddする Loop Dim len As Integer 'TextBox1に入力された線の長さ←テキストファイルの1列目(X) Dim angledouble As Double 'TextBox2に入力された角度 単位は度  '変数が競合するため名前を変更しました。 Dim ansx As Double '計算された、xの座標 Dim ansy As Double '計算された、yの座標 '変数の宣言() Dim w As Integer Dim k As Integer '変数が競合するため名前を変更しました。 For k = 0 To 5 'fileの行が6と仮定 (6列6行) For w = 0 To 99 len = CDbl(ar(k) / 2) 'ar(k)は1列目(X)の値です angledouble = CDbl(angledouble + 90) ansx = X + len * (Math.Cos(angledouble / 180 * Math.PI)) '終点のx座標 ansy = y + len * (Math.Sin(angledouble / 180 * Math.PI)) '終点のy座標 cadStartPoint.x = ansx * -1 cadStartPoint.y = ansy * -1 cadEndPoint.x = ansx cadEndPoint.y = ansy w = w + 1 Next Next Catch ex As Exception '各変数が適用範囲外になりますので、ここに移動しました。 MessageBox.Show(ex.Message, "read") Finally If sr IsNot Nothing Then sr.Close() sr.Dispose() End If End Try f2.println() 'PictureBoxに表示するメソッド f2.Show() 'Form2をShowする End Sub わからない場合の方法 1.むりをして頑張る。 2.あきらめる。 私は2.「あきらめる」をお勧めします。 1.「むりをして頑張る」は意欲の低下や体調不良につながりますね。 「あきらめる」といっても、単純にあきらめるのではありません。 「あきらめる」とは #時間をおく 次の日にもう一度プログラムを見直すと前日にはわからなかったエラーの原因がすんなりわかったりします。 別の方法でプログラムできるのなら、エラーのでるところを削除して別の方法でプログラムしてしまいましょう。 #人に聞く 解決できない場合は人に聞くしかありません。 「人」といっても実際の知り合いばかりではなく、インターネットや本・雑誌なども含みます。 このサイトも「人に聞く」にあたります。どんどん活用しましょう。 はじめは理解できない部分が多いと思いますが、その場合はコピペできるように、回答者さんにお願いしましょう。 そのうち、理解できるようになります。 だいぶ、日にちが過ぎていますので、別スレッドで再質問してもいいですね。 わからないときは、気軽に質問してね。

  • digitalian
  • ベストアンサー率29% (323/1104)
回答No.2

'変数の宣言 Dim w As Integer Dim i As Integer '初期化 w = 0 'ここでwを0にしておきながら i = 0 For w As Integer = 1 To 100 'ここでまたwを1で定義しなおしているのが変。 len = CDbl("x1" / 2) angle = CDbl(angle + 90) ansx = X + len * (Math.Cos(angle / 180 * Math.PI)) '終点のx座標 ansy = y + len * (Math.Sin(angle / 180 * Math.PI)) '終点のy座標 cadStartPoint.x = ansx * -1 cadStartPoint.y = ansy * -1 cadEndPoint.x = ansx cadEndPoint.y = ansy w = w + 1 'この行は要らない。 Next やるならこうです。 × For w As Integer = 1 To 100 ◯ For w = 1 To 100

  • kokorone
  • ベストアンサー率38% (417/1093)
回答No.1

For ループの数行前で、wを定義し、0で初期化しているのに、 For 文で、 As Integer で再定義していますが、これは、故意ですか? また、Forループの中で、w=w+1とカウントアップしていますが、これも故意ですか? For ループの変数をw以外にしたら、どうなりますか?

関連するQ&A

  • VB TEXTデータについて

    下記のコードでTEXTを読み取りできましたが、読み取ったデータを使用して座標計算したいのですが 例えば、6列6行あるとします、1列目(X)、2列目(y)、3列目(X1)、4列目(y2)、5列目(角度)、6列目(予備)、となっているものが6行あります、1列目・1行の値から、6列目・6行の値まで指定するとき どのようなコードがあるのでしょうか、宜しくお願いします。 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim sr As System.IO.StreamReader = Nothing ' Try Dim file As String = TextBox1.Text 'SRとは New System.IO.StreamReaderの略 sr = New System.IO.StreamReader(file, System.Text.Encoding.GetEncoding("shift_jis")) Dim doc As String = "" '1行ずつテキストを読み取る Do Until sr.EndOfStream '改行コードが取り除かれてしまうのでVBnewlineで改行を付け直し doc &= sr.ReadLine & vbNewLine Loop 'TEXTBOX.2にdocを代入 TextBox2.Text = doc Catch ex As Exception MessageBox.Show(ex.Message, "read") Finally If sr IsNot Nothing Then sr.Close() sr.Dispose() End If End Try End Sub

  • VBA  FOR・・・・NEXについて

    ★から★までのコードがどうしても成立しません、★以外は線分としてコードが成立するのですが ★から★を入れると成立しません。どう構築したいいのでしょうか、宜しくお願いします。 エクセルでCVSファイルの数値を線分として図面に記入するためのコードになります。 説明不足ですが、宜しくお願いします。 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click ' LineData用の変数です。 Dim cadLineData As New zwDrawCAD.LineData Dim cadStartPoint As zwDrawCAD.DPoint = cadLineData.Start Dim cadEndPoint As zwDrawCAD.DPoint = cadLineData.End 'とりあえず線のスタート点は(100,100)にしてます。 Const X As Integer = 100 'cadStartPoint.x = 100 Const Y As Integer = 100 'cadStartPoint.y = 100 Const xx As Integer = 5 Const yy As Integer = 6 Dim len As Integer 'TextBox1に入力された線の長さ Dim angle As Double 'TextBox2に入力された角度 単位は度 Dim ansx As Integer '計算された、xの座標 Dim ansy As Integer '計算された、yの座標  ★ Dim ddd(5, 6) As Integer 'TEXTの階数 xx = 5 yy = 6 FILETIME = "c:\DummyData.csv" Open Filename For Input As #1 For i = 1 To yy For j = 1 To xx Input #1, ddd(xx, yy) Next j Next i ★ Close #1 len = CDbl(TextBox5.Text / 2) angle = CDbl(TextBox2.Text + 90) ansx = X + len * (Math.Cos(angle / 180 * Math.PI)) '終点のx座標 ansy = Y + len * (Math.Sin(angle / 180 * Math.PI)) '終点のy座標 cadStartPoint.x = 100 cadStartPoint.y = 100 cadEndPoint.x = ansx cadEndPoint.y = ansy ' 参照したオブ ジェクトを解放します。 System.Runtime.InteropServices.Marshal.ReleaseComObject(cadStartPoint) ' アクティブなDocumentを参照します。 Dim cadDocument As zwDrawCAD.Document = cadApplication.ActiveDocument ' 現在の作図属性を参照します。 Dim cadCurrentDraw As zwDrawCAD.DrawData = cadDocument.CurrentDraw ' 現在のレイヤ、線種、線幅、線色を設定します。 cadLineData.LayerNo = cadCurrentDraw.LayerNo cadLineData.PenStyle = cadCurrentDraw.PenStyle cadLineData.PenWidth = cadCurrentDraw.PenWidth cadLineData.PenColor = cadCurrentDraw.PenColor ' 参照したオブジェクトを解放します。 System.Runtime.InteropServices.Marshal.ReleaseComObject(cadCurrentDraw) ' データベースを参照します。 Dim cadDataBase As zwDrawCAD.CADDB = cadDocument.DataBase ' Undo情報を設定します。 cadDataBase.SetDelimitter("始点座標(100,100) 終点座標((ansx,ansy) の線分") ' 追加した要素の参照用変数です。 Dim cadAddPrimitive As zwDrawCAD.Primitive ' 要素を追加します。 cadAddPrimitive = cadDataBase.Add(cadLineData) ' 参照したオブジェクトを解放します。 System.Runtime.InteropServices.Marshal.ReleaseComObject(cadAddPrimitive) System.Runtime.InteropServices.Marshal.ReleaseComObject(cadLineData) System.Runtime.InteropServices.Marshal.ReleaseComObject(cadDataBase) System.Runtime.InteropServices.Marshal.ReleaseComObject(cadDocument)

  • VBA FOR・・・・NEXTについて

    ★から★までのコードがどうしても成立しません、★以外は線分としてコードが成立するのですが ★から★を入れると成立しません。どう構築したいいのでしょうか、宜しくお願いします。 エクセルでCVSファイルの数値を線分として図面に記入するためのコードになります。 説明不足ですが、宜しくお願いします。 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click ' LineData用の変数です。 Dim cadLineData As New zwDrawCAD.LineData Dim cadStartPoint As zwDrawCAD.DPoint = cadLineData.Start Dim cadEndPoint As zwDrawCAD.DPoint = cadLineData.End 'とりあえず線のスタート点は(100,100)にしてます。 Const X As Integer = 100 'cadStartPoint.x = 100 Const Y As Integer = 100 'cadStartPoint.y = 100 Const xx As Integer = 5 Const yy As Integer = 6 Dim len As Integer 'TextBox1に入力された線の長さ Dim angle As Double 'TextBox2に入力された角度 単位は度 Dim ansx As Integer '計算された、xの座標 Dim ansy As Integer '計算された、yの座標  ★ Dim ddd(5, 6) As Integer 'TEXTの階数 xx = 5 yy = 6 FILETIME = "c:\DummyData.csv" Open Filename For Input As #1 For i = 1 To yy For j = 1 To xx Input #1, ddd(xx, yy) Next j Next i ★ Close #1 len = CDbl(TextBox5.Text / 2) angle = CDbl(TextBox2.Text + 90) ansx = X + len * (Math.Cos(angle / 180 * Math.PI)) '終点のx座標 ansy = Y + len * (Math.Sin(angle / 180 * Math.PI)) '終点のy座標 cadStartPoint.x = 100 cadStartPoint.y = 100 cadEndPoint.x = ansx cadEndPoint.y = ansy ' 参照したオブ ジェクトを解放します。 System.Runtime.InteropServices.Marshal.ReleaseComObject(cadStartPoint) ' アクティブなDocumentを参照します。 Dim cadDocument As zwDrawCAD.Document = cadApplication.ActiveDocument ' 現在の作図属性を参照します。 Dim cadCurrentDraw As zwDrawCAD.DrawData = cadDocument.CurrentDraw ' 現在のレイヤ、線種、線幅、線色を設定します。 cadLineData.LayerNo = cadCurrentDraw.LayerNo cadLineData.PenStyle = cadCurrentDraw.PenStyle cadLineData.PenWidth = cadCurrentDraw.PenWidth cadLineData.PenColor = cadCurrentDraw.PenColor ' 参照したオブジェクトを解放します。 System.Runtime.InteropServices.Marshal.ReleaseComObject(cadCurrentDraw) ' データベースを参照します。 Dim cadDataBase As zwDrawCAD.CADDB = cadDocument.DataBase ' Undo情報を設定します。 cadDataBase.SetDelimitter("始点座標(100,100) 終点座標((ansx,ansy) の線分") ' 追加した要素の参照用変数です。 Dim cadAddPrimitive As zwDrawCAD.Primitive ' 要素を追加します。 cadAddPrimitive = cadDataBase.Add(cadLineData) ' 参照したオブジェクトを解放します。 System.Runtime.InteropServices.Marshal.ReleaseComObject(cadAddPrimitive) System.Runtime.InteropServices.Marshal.ReleaseComObject(cadLineData) System.Runtime.InteropServices.Marshal.ReleaseComObject(cadDataBase) System.Runtime.InteropServices.Marshal.ReleaseComObject(cadDocument)

  • ※VBA配列

    http://oshiete1.goo.ne.jp/qa5196795.htmlで 質問させてもらった者です。質問不足だったため 質問の内容を追加したかったのですが、追加の方法がわからず またこちらで質問させていただきました Dim time1 As Integer, time As Integer Dim X As Integer, Y As Integer Dim X1 As Integer, Y1 As Integer Dim X2 As Integer, Y2 As Integer Dim maru As String, yoko As String, tate As String Dim sankaku As String, shikaku As String Sub 描画() Cells(Y2, X2).Value = shikaku Cells(Y1, X1).Value = sankaku Cells(Y, X).Value = maru End Sub Sub 削除() Cells(Y2, X2).Value = "" End Sub Sub 待機() For time1 = 0 To 1000 For time2 = 0 To 1000 Next Next End Sub Sub 座標移動() X2 = X1 Y2 = Y1 X1 = X Y1 = Y If yoko = "右" Then X = X + 1 Else X = X - 1 End If If X = 30 Then yoko = "左" ElseIf X = 1 Then yoko = "右" End If If tate = "上" Then Y = Y + 1 Else Y = Y - 1 End If If Y = 20 Then tate = "下" ElseIf Y = 1 Then tate = "上" End If End Sub Sub main() maru = "●" sankaku = "▲" shikaku = "■" X = 1 Y = 1 X1 = 1 Y1 = 1 X2 = 1 Y2 = 1 yoko = "右" tate = "上" Do 描画 待機 削除 待機 座標移動 Loop End Sub a~tの文字が、上記のような動きをする プログラムを作成するにはどのように配列を活かせばいいですか? 配列がよくわかっておらず勉強したのですが…使えずにいます;;

  • Excel VBA ・・・教えてください

    何度も質問させて頂いてます。すみません、 下記のプログラムはこの場で教えて頂いたプログラムで、 実行すると●の後を▲や■が追いかける動きをします。 下記のプログラムをある程度使用して 1~20の数字が順々で追いかけっこする プログラムを作成するにはどのようにすればいいのでしょうか… できればプログラムは長めにならず 20の数字から簡単に増やすことのできるような そんなプログラムが作成したいです… どなたかアドバイスお持ちの方 教えて下さいお願いします... Dim time1 As Integer, time As Integer Dim X As Integer, Y As Integer Dim X1 As Integer, Y1 As Integer Dim X2 As Integer, Y2 As Integer Dim maru As String, yoko As String, tate As String Dim sankaku As String, shikaku As String Sub 描画() Cells(Y2, X2).Value = shikaku Cells(Y1, X1).Value = sankaku Cells(Y, X).Value = maru End Sub Sub 削除() Cells(Y2, X2).Value = "" End Sub Sub 待機() For time1 = 0 To 1000 For time2 = 0 To 1000 Next Next End Sub Sub 座標移動() X2 = X1 Y2 = Y1 X1 = X Y1 = Y If yoko = "右" Then X = X + 1 Else X = X - 1 End If If X = 30 Then yoko = "左" ElseIf X = 1 Then yoko = "右" End If If tate = "上" Then Y = Y + 1 Else Y = Y - 1 End If If Y = 20 Then tate = "下" ElseIf Y = 1 Then tate = "上" End If End Sub Sub main() maru = "●" sankaku = "▲" shikaku = "■" X = 1 Y = 1 X1 = 1 Y1 = 1 X2 = 1 Y2 = 1 yoko = "右" tate = "上" Do 描画 待機 削除 待機 座標移動 Loop End Sub

  • VBAでのデータ転記(再)

    データがsheet1に縦記述で書いてあります。 C列 D列 ああ A01 いい A02 うう A03 . ささ B01 しし B02 すす B03 . はは AA01 ひひ AA02 ふふ AA03 . やや AB01 ゆゆ AB02 よよ AB03 . D列を元にしてC列の文字列をsheet2に以下のように並べたいです。D列はアドレス扱いででアルファベットが変わったら改行してデータを並べるようにします。 A列  B列 C列 ああ いい うう・ ささ しし すす・ ・・・・・ はは ひひ ふふ・ やや ゆゆ よよ・ 作成したコード Dim I As Integer, MAE As String, IMA As String, TEMP2 As String Dim X1 As Integer, Y1 As Integer, X3 As Integer, Y3 As Integer, PINNAME As String X1 = 4: Y1 = 2 X3 = 1: Y3 = 1 MAE = Sheets("Sheet1").Cells(Y1, X1) Do PINNAME = Sheets("Sheet1").Cells(Y1, X1 - 1) IMA = Sheets("Sheet1").Cells(Y1, X1) '今の値が入っている If IMA = "" Then Exit Do End If If Left(MAE, 1) <> Left(IMA, 1) Then Y3 = Y3 + 1: X3 = 1 Sheets("Sheet2").Cells(Y3, X3).Value = PINNAME X3 = X3 + 1 Else Sheets("Sheet2").Cells(Y3, X3).Value = PINNAME X3 = X3 + 1 End If MAE = Sheets("Sheet1").Cells(Y1, X1) Y1 = Y1 + 1 Loop Until IMA = "" Left関数でアドレスの左1文字を前後のセルで比較して異なる場合、改行する方法を考えましたが、AA01 AA02・・・がムリです。このコードに補足すればできるでしょうか?それとも別の考え方で行った方がいいでしょうか? 初心者レベルなので考え方も教えて下さい。宜しくお願いします。

  • VB2005 図形

    VisualBasic2005で Dim n As Integer, m As Integer Dim i As Integer, j As Integer Const lenn = 1500, PAI = 3.14159 Dim th As Single, th1 As Single, th2 As Single Dim x1 As Integer, x2 As Integer Dim y1 As Integer, y2 As Integer n = Val(TextBox1.Text) m = Val(TextBox2.Text) If n < 2 Or m < 2 Then   Exit Sub End If For i = 0 To n - 1   For j = 1 To n - 1     th = j * (PAI / n)     th1 = i * (PAI / m) + th     th2 = i * (PAI / n) - th     x1 = Math.Cos(th1) * lenn + 2000     y1 = Math.Sin(th1) * lenn + 2000      x2 = Math.Cos(th2) * lenn + 2000      y2 = Math.Sin(th2) * lenn + 2000   Next Next の様なコードを使って 球をPictureBoxに書きたいのですが どこにどんなコードが足りないのでしょうか? 教えて下さい

  • VB.NETのメモリ領域について

    VB.NETのメモリ領域について 以下の(1)~(12)の変数のために、 スタック領域、静的領域、ヒープ領域のどこのメモリが使われるか教えてください。 Class Sample   Dim a As Integer '(1)   Dim b As String = "BBB" '(2)   Shared c As Integer '(3)   Shared d As String = "DDD" '(4)   Sub X()     Dim f As Integer '(5)     Dim g As String = "GGG" '(6)     Static h As Integer '(7)     Static i As String = "III" '(8)   End Sub   Shared Sub Y()     Dim k As Integer '(9)     Dim l As String = "LLL" '(10)     Static m As Integer '(11)     Static n As String = "NNN" '(12)   End Sub End Class それぞれこんな認識で合ってますか? スタック領域 (1)(5)(9) スタック領域にポインタ+ヒープ領域に実体 (2)(6)(10) 静的領域 (3)(7)(11) 静的領域にポインタ+ヒープ領域に実体 (4)(8)(12)

  • エラー"Next"に対する"for"がありません

    EXCELのVBAで、A列3行目から入力されているデータ(A列2行目タイトル="FA")を 一度全て半角に変換し、変換した"変換文字"から"!"や"#"の記号をASC関数を利用し 削除、記号だけを削除した文字列をE列に取得しようとしていますが NEXTにたいするFORがありませんとエラーが出てしまいます。 TARGETの設定の仕方が悪いのでしょうか? (win7/EXCEL2010使用) Dim セル As Range Dim TARGET As Range Dim 変換文字 As String Dim i As Long Dim W As Worksheet Set W = Sheets("DATA転記") Set TARGET = W.Range("A3", Range("A65536").End(xlUp)) For Each セル In TARGET 変換文字 = StrConv(セル.Text, vbNarrow) For i = 1 To Len(変換文字) If Asc(変換文字) >= 32 And Asc(変換文字) <= 47 And _ Asc(変換文字) >= 58 And Asc(変換文字) <= 64 And _ Asc(変換文字) >= 91 And Asc(変換文字) <= 96 And _ Asc(変換文字) >= 123 And Asc(変換文字) <= 126 Then _ 変換文字 = WorksheetFunction.Replace(変換文字, i, 1, "") Next i セル.Cells(, 5).Value = 変換文字 Next セル

  • VB.NETの関数プロシージャの書き方を教えてください。

    Public A As String という変数にある文字列データが入っていて、 ボタンを押すとその時に変数X,Y,Zに入っている 文字列を検索してButton1_Clickプロシージャ内に戻って来て KekkaX,KekkaY,KekkaZに数値が入るような関数プロシージャなのですが、 呼び出す部分の書き方と関数のプロシージャ名の書き方を教えて頂きたいです。 検索する部分は自分で出来ると思うので大丈夫です。 Public A As String = "何かの文字列" Button1_Click Dim X,Y,Z As String Dim KekkaX,KekkaY,KekkaZ as Integer '変数Aの中からX,Y,Zを検索したい X="*****" Y="ABCDE" Z="#####" GetKensakuKekka(????????) ←この部分の書き方を教えて下さい。 'KekkaX,KekkaY,KekkaZ 内に検索結果を取得したい Console.WriteLine(KekkaX) Console.WriteLine(KekkaY) Console.WriteLine(KekkaZ) End Sub Function GetKensakuKekka (???????????) ←この部分の書き方を教えて下さい。 ・ ・ ・ End Function よろしくお願い致します。

専門家に質問してみよう