質問編集履歴

4

誤記修正

2016/12/02 05:25

投稿

suban
suban

スコア28

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  **********送信部***********
10
10
 
11
- '''
11
+ ```
12
12
 
13
13
  'テキストボックスから、送信するテキストを取り出す.
14
14
 
@@ -68,7 +68,7 @@
68
68
 
69
69
  Next
70
70
 
71
- '''
71
+ ```
72
72
 
73
73
  <追記>
74
74
 
@@ -92,7 +92,7 @@
92
92
 
93
93
  *************************
94
94
 
95
- '''
95
+ ```
96
96
 
97
97
  'テキストボックスから、送信するテキストを取り出す.
98
98
 
@@ -124,4 +124,4 @@
124
124
 
125
125
  SerialPort1.Write(ByteArray, 0, ByteArray.Length)
126
126
 
127
- '''
127
+ ```

3

コードブロックを追加

2016/12/02 05:24

投稿

suban
suban

スコア28

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,9 @@
8
8
 
9
9
  **********送信部***********
10
10
 
11
+ '''
12
+
11
- 'テキストボックスから、送信するテキストを取り出す.
13
+ 'テキストボックスから、送信するテキストを取り出す.
12
14
 
13
15
  'Dim data As String
14
16
 
@@ -66,7 +68,7 @@
66
68
 
67
69
  Next
68
70
 
69
-
71
+ '''
70
72
 
71
73
  <追記>
72
74
 
@@ -90,32 +92,36 @@
90
92
 
91
93
  *************************
92
94
 
95
+ '''
96
+
93
97
  'テキストボックスから、送信するテキストを取り出す.
94
98
 
95
- Dim data As String
99
+ Dim data As String
96
100
 
97
- data = SndTextBox.Text
101
+ data = SndTextBox.Text
98
102
 
99
103
 
100
104
 
101
105
  '送信するテキストがない場合、データ送信は行わない.
102
106
 
103
- If String.IsNullOrEmpty(data) Then
107
+ If String.IsNullOrEmpty(data) Then
104
108
 
105
- Return
109
+ Return
106
110
 
107
- End If
111
+ End If
108
112
 
109
113
 
110
114
 
111
- Try
115
+ Try
112
116
 
113
- 'シリアルポートからテキストを送信する.
117
+ 'シリアルポートからテキストを送信する.
114
118
 
115
- Dim ByteArray As Byte()
119
+ Dim ByteArray As Byte()
116
120
 
117
- ByteArray = System.Text.Encoding.GetEncoding(65001).GetBytes(data) ' UTF8
121
+ ByteArray = System.Text.Encoding.GetEncoding(65001).GetBytes(data) ' UTF8
118
122
 
119
- 'ByteArray = System.Text.Encoding.GetEncoding(932).GetBytes(data) ' SJIS
123
+ 'ByteArray = System.Text.Encoding.GetEncoding(932).GetBytes(data) ' SJIS
120
124
 
121
- SerialPort1.Write(ByteArray, 0, ByteArray.Length)
125
+ SerialPort1.Write(ByteArray, 0, ByteArray.Length)
126
+
127
+ '''

2

追記を追加

2016/12/02 05:22

投稿

suban
suban

スコア28

test CHANGED
File without changes
test CHANGED
@@ -65,3 +65,57 @@
65
65
  w = w + 1
66
66
 
67
67
  Next
68
+
69
+
70
+
71
+ <追記>
72
+
73
+ SerialPort1.Writeメソッドの引数のLengthが書き込むバイト数で
74
+
75
+ ここの値を変えるとよいように思いますが、数値に置き換えても
76
+
77
+ エラーでうまくいきませんでした。
78
+
79
+ 下記は、本来のテキストBOXから送信するプログラムですが
80
+
81
+ テキストBOXに、数文字書くと連続して送信しました。
82
+
83
+
84
+
85
+ 私が、やりたい事は固定の数バイトのデータを連続して送信
86
+
87
+ したいのですが
88
+
89
+
90
+
91
+ *************************
92
+
93
+ 'テキストボックスから、送信するテキストを取り出す.
94
+
95
+ Dim data As String
96
+
97
+ data = SndTextBox.Text
98
+
99
+
100
+
101
+ '送信するテキストがない場合、データ送信は行わない.
102
+
103
+ If String.IsNullOrEmpty(data) Then
104
+
105
+ Return
106
+
107
+ End If
108
+
109
+
110
+
111
+ Try
112
+
113
+ 'シリアルポートからテキストを送信する.
114
+
115
+ Dim ByteArray As Byte()
116
+
117
+ ByteArray = System.Text.Encoding.GetEncoding(65001).GetBytes(data) ' UTF8
118
+
119
+ 'ByteArray = System.Text.Encoding.GetEncoding(932).GetBytes(data) ' SJIS
120
+
121
+ SerialPort1.Write(ByteArray, 0, ByteArray.Length)

1

サンプルプログラムを明示

2016/12/02 01:23

投稿

suban
suban

スコア28

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,10 @@
1
1
  VBで、シリアル通信(COMポート)から、バイナリデータを連続送信したいのですが、サンプルプログラムの改造で、文字列送信からバイナリ送信に変更は出来たのですが、連続したバイナリデータを送信しますと、1バイト毎にウエイトが入ってしまいます。
2
2
 
3
3
 
4
+
5
+ 参考にしたサイトはこちらです
6
+
7
+ http://kana-soft.com/tech/sample_0008.htm
4
8
 
5
9
  **********送信部***********
6
10