我试图创建一个基本的解释器,但数据网格中输出的显示方式是逐字逐句而不是逐字逐句。看图片。 wrong way right way
这是我到目前为止所得到的:
Public Class Form1
Dim nro_letras As Integer
Dim cont As Integer
Dim cadena As String
Dim conversion As String
Dim palabras As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
cont = 0
For atun As Integer = 1 To nro_letras
conversion = Mid(cadena, atun, 1)
Select Case Asc(conversion)
Case 0 To 32
MsgBox("este caracter no es valido")
Case Is >= 125
MsgBox("este caracter no es valido")
Case Else
palabras = palabras & conversion
End Select
If DataGridView1.RowCount = cont Then DataGridView1.Rows.Add()
DataGridView1.Item(0, cont).Value = cont
DataGridView1.Item(1, cont).Value = palabras
cont += 1
palabras = ""
Next
cont += 1
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
nro_letras = TextBox1.TextLength 'Digo que el numero de letras es todo lo que usuario escriba'
cadena = TextBox1.Text 'lo que esta escrito en el textbox es mi string'
End Sub
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
End Sub
End Class
答案 0 :(得分:1)
汉斯是对的,它做的是你告诉它的。要让行包含整个单词,您需要将Sub for Button1_Click的当前代码放在另一个循环中。为您提供一个开始