扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
vb.net:
创新互联建站专业为企业提供尖山网站建设、尖山做网站、尖山网站设计、尖山网站制作等企业网站建设、网页设计与制作、尖山企业网站模板建站服务,十余年尖山做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
Dim path = System.IO.Directory.GetFiles("D:\Log\abc", "*.txt", SearchOption.AllDirectories):搜索该路径下的所有txt类型的目录及子目录
path.AddRange(path)
Dim _RecordInfo As String
Dim _Reader As StreamReader
_Reader = New StreamReader(file, System.Text.Encoding.Default):'以Default编码的形式读取file文件(文件写入的编码要与读取的编码一致)
可以的,需要判断控件类型并做一下类型转换。
For Each c As Control In Me.Controls
If TypeOf(c) Is TextBox Then
Dim t As TextBox = CType(c ,TextBox)
'调用t的方法即可
End If
Next
For Each ctl As Control In Me.Controls If TryCast(ctl, TextBox) Nothing Then Dim txt As TextBox = TryCast(ctl, TextBox) txt.Text = "" End If
遍历的例子:
Dim i, j As Integer
For i = 0 To DataGridView1.RowCount - 1
For j = 0 To DataGridView1.ColumnCount - 1
MsgBox(DataGridView1.Item(j, i).Value)
Next
Next
注意:与Excel的单元格命名规则不一样,这里的 Item(j, i) 中,列号 j 在前,行号 i 在后。
Public Sub ReSetText(Control ctrl)
Dim ct As Control
For Each ct In ctrl.Controls
Try
For Each ct2 As Control In ct.Controls
ReSetText(ct2)
Next
Catch
End Try
If (TypeOf ct Is TextBox) Then
ct.Text = ""
ElseIf (TypeOf ct Is ComboBox) Then
Dim cb As System.Windows.Forms.ComboBox = DirectCast(ct, System.Windows.Forms.ComboBox)
cb.SelectedIndex = -1
End If
Next
End Sub
因为textbox在窗体里的panel里,你只遍历窗体的控件是不够的。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流