kidness123 2016-08-19 12:03 采纳率: 0%
浏览 855
已结题

vb改写成c#的问题提问

Private Sub Cmdback_Click()
Unload Me
End Sub

Private Sub Comboclass_Click()
Refresh_culture
End Sub

Private Sub Combofour_Click()
Refresh_culture
End Sub

Private Sub Combospecialty_Click()
Dim i As Long
Dim Tmpspecialty As Long
If Combospecialty.ListIndex = 0 Then
Comboclass.Visible = False
Combofour.Visible = True
Else
Comboclass.Visible = True
Comboclass.Clear
Comboclass.AddItem "全部"
'装入二级类目
TmpType = MyClass.GetId(Combospecialty.Text)
MyClass.Load_by_Upper (TmpType)
i = 0
Do While Arr_ClassName(i) <> ""
Comboclass.AddItem Arr_ClassName(i)
i = i + 1
Loop
Comboclass.ListIndex = 0
End If
Refresh_culture
End Sub

Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)

xlSheet.Columns.AutoFit
Me.MousePointer = 11
For k = 0 To DataGrid1.Columns.Count - 1 'DataGrid所有的列数
xlSheet.Cells(1, k + 1) = DataGrid1.Columns(k).Caption '第一行为DataGrid的列标题
Next
DataGrid1.Scroll 0, -DataGrid1.FirstRow '导出前拉动过垂直滚动条,这个非常重要
DataGrid1.Row = 0
For i = 0 To DataGrid1.ApproxCount - 1 'DataGrid的所有行数

  For j = 0 To DataGrid1.Columns.Count - 1 'DataGrid所有的列数,若将此数改小到不拉DataGrid的垂直滚动条的时候能看见的行数的时候正常
     DataGrid1.Col = j
     xlSheet.Cells(i + 2, j + 1) = Adodc1.Recordset(j) 'DataGrid1.Text '从第二行显示'DataGrid的内容
  Next
 If i < DataGrid1.ApproxCount - 1 Then
   DataGrid1.Row = DataGrid1.Row + 1
 End If

Next
Me.MousePointer = 0
MsgBox "导出成功!"
xlApp.Visible = True
Set xlApp = Nothing 'Excel 处于当前窗体
Set xlBook = Nothing
Set xlSheet = Nothing
End Sub

Private Sub DataGrid1_Click()

End Sub

Private Sub Form_Load()
Dim i As Integer
'装入一级类目
Combospecialty.AddItem "全部"
MyClass.Load_by_Upper (0)
i = 0
Do While Arr_ClassName(i) <> ""
Combospecialty.AddItem Arr_ClassName(i)
i = i + 1
Loop
Combospecialty.ListIndex = 0
'不显示二级类目
Comboclass.Visible = False
Combofour.ListIndex = 0

End Sub
Private Sub Refresh_culture()
Dim TmpSource As String
TmpSource = "SELECT S.Student_Id as 学生序号,S.Student_Name as 姓名,S.BadgeID as 学号, " _
+ " C1.Class_Name as 专业名称,C2.class_name as 班级名称,convert(char,F.Student_Grade) as 学年,F.yearinput as 年度," _
+ "F.Cet_Four as 四级成绩, F.Cet_Six as 六级成绩, F.NationPC_Two as 全国计算机二级成绩, " _
+ "F.NationPC_Three as 全国计算机三级成绩, F.NationPC_Four as 全国计算机四级成绩, F.JsPC_Two as 江苏计算机二级成绩," _
+ "F.JsPC_Three as 江苏计算机三级成绩,F.Basicjudge_Type as 基本素质测评类型,F.Basicjudge_Score as 基本素质测评分,F.grow_score as 发展素质分," _
+ "F.Culture_Memo as 文化备注 " _
+ "FROM Students S,Classes C1,classes C2 ,Student_four F" _
+ " WHERE S.Class_Id = C2.Class_Id And S.student_ID=f.student_ID and C2.UpperId =C1.class_ID And S.Student_Id = F.Student_Id "
If Combospecialty.ListIndex <> 0 Then
If Comboclass.ListIndex = 0 Then
TmpSource = TmpSource + " and C1.class_name='" + Trim(Combospecialty.Text) + "'"
Else
TmpSource = TmpSource + " and C1.class_name='" + Trim(Combospecialty.Text) _
+ "' and C2.class_name='" + Trim(Comboclass.Text) + "'"
End If
End If

TmpSource = TmpSource + " and cast(F.Student_Grade as char)='" + Trim(Combofour.Text) + "'"
TmpSource = TmpSource + " order by s.student_ID asc"
Adodc1.RecordSource = TmpSource
Adodc1.Refresh
DataGrid1.Refresh

If Adodc1.Recordset.EOF = True Then
'MsgBox "没有数据可供导出!"
Command1.Enabled = False
Else
Command1.Enabled = True
End If

End Sub
图片说明
怎么在vs用c#实现这个功能
详细些,谢谢帮助

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-08-19 15:50
    关注

    vb改写成C#基本就是根据需求重写一遍了。你得雇个程序员帮你了。

    评论

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的