重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
在窗体上加上三个标签控件:Label1、Label2、Label3
创新互联是一家专注于成都网站设计、网站制作和达州服务器托管的网络公司,有着丰富的建站经验和案例。
Private Sub DataGridView1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseUp
Dim counter As Integer
Dim SelectedCellTotal As Integer = 0
Dim SelectedCellCount As Integer = 0
For counter = 0 To (DataGridView1.SelectedCells.Count - 1)
If DataGridView1.SelectedCells(counter).FormattedValueType Is _
Type.GetType("System.String") Then
Dim value As String = Nothing
If (DataGridView1.IsCurrentCellDirty = True) Then
value = DataGridView1.SelectedCells(counter).EditedFormattedValue.ToString()
Else
value = DataGridView1.SelectedCells(counter).FormattedValue.ToString()
End If
If value IsNot Nothing Then
If Not value.Length = 0 Then
SelectedCellTotal = SelectedCellTotal + Integer.Parse(value)
SelectedCellCount = SelectedCellCount + 1
End If
End If
End If
Next
Label1.Text = "选中的单元格个数为: " SelectedCellCount.ToString()
Label2.Text = "单元格里数据之和为: " SelectedCellTotal.ToString()
Label3.Text = "选中的单元格行数为:" DataGridView1.SelectedRows.Count.ToString()
End Sub
Dim str As String = "", temp, n As Integer
Dim str1 As String = "12,45,2,9,41,31,66,83,2,1,-9,-91,-21"
Dim a() As String = Split(str1, ",")
For i = 1 To UBound(a) Step 1
a(i) = Val(a(i))
Next
temp = 0
n = 0
For i = 1 To UBound(a)
If a(i) temp Then
temp = a(i)
End If
If a(i) 0 Then
n = n + 1
End If
Next
str = str "正数的个数为 " n
str = str "最大元素的下标为 "
For i = 1 To UBound(a)
If a(i) = temp Then
str = str i " "
End If
Next
TextBox6.Text = str
是不是这样:
private
sub
form_load()
dim
r
as
string
open
"c:\1.txt"
for
input
as
#1
'假设你的文档是c:\1.txt
do
while
not
eof(1)
line
input
#1,r
combo1.additem
r
loop
close
#1
end
sub
如果这样,就直接用1.txt,但要注意的是你的1.txt要和你的程序放在同一文件夹中。
点击“开始”-“Excel选项”,在“基本设置”选项卡中勾选右侧的“在功能区上显示‘开发工具’”,使其显示出来。
切换到“开发工具”功能区,点击插入”下拉列表框,在弹出的列表中选择“复选框(ActiveX控件)”。
然后在文档区域拖动以绘制一个复选框。 并在该复选框上右键单击,在弹出的菜单中选择“属性”以打开“属性对话框”。
在打开的“属性对话框”中将“Caption”设置为空,”BackStyle“设置为透明,边框效果设置为0类型,完成后关闭”属性对话框“。
有两种实现方式,一种是使用后台的事件CheckedChanged、Clicked、MouseDown等等都可以,另一种是用js的onclick事件,不过代码都差不多。
If CheckBox1.Checked = True Then
'选中时
TextBox1.Text = '说话'
Else
'未选中时
TextBox1.Text = ''
End If