Public Class CARD_DECK_ENTRY 公共myConString As String Dim con As New OleDb.OleDbConnection Dim myStream As Stream = Nothing
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
Operator_ID.Close()
End Sub
Private Sub OpenFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenFileToolStripMenuItem.Click
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "mdb files (*.mdb)|*.mdb|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 1
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Try
myStream = openFileDialog1.OpenFile()
If (myStream IsNot Nothing) Then
myConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & openFileDialog1.FileName
Dim x As String = openFileDialog1.FileName.Substring(0, openFileDialog1.FileName.Length - 20) & "Images"
con.ConnectionString = myConString
con.Open()
datagridshow()
End If
Catch Ex As Exception
MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
Finally
' Check this again, since we need to make sure we didn't throw an exception on open.
If (myStream IsNot Nothing) Then
myStream.Close()
End If
End Try
End If
End Sub
Private Sub CARD_DECK_ENTRY_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = myConString
con.Open()
datagridshow()
End Sub
Private Sub datagridshow()
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
da = New OleDbDataAdapter("Select * from Data001", con)
da.Fill(dt)
DataGridView1.DataSource = dt.DefaultView
con.Close()
End Sub
我现在得到Tim,但现在我要在浏览mdb的同时将图像加载到imageViewer中。正如你在上面的代码中看到的,有(“Select * from Data001”,con)因为它是一个我将在DataGridView上显示的表。在数据库上有两个表,分别是“CardDeck”和“Data001”。在CardDeck中有一个“Image001”专栏。此列包含tif图像名称。在找到数据库的文件夹上,在同一路径(数据库文件夹的路径)上有另一个名为“Images”的文件夹。在那里可以找到“Image001”的列值。我的观点是如何将这些“Image001”列值浏览到ImageViewer,其中这些值位于文件夹“Images”中?请帮忙。 :'(
答案 0 :(得分:1)
你想要一个整数除法,VB.NET拥有它自己的\
运算符:
Dim result As Int32 = 25 \ 9 + 1
因此,公共/
- 运算符返回带有除法结果的double。在C#中,其中一个都需要是浮点类型以避免整数除法(删除余数)。
另一种方法是使用Math.Ceiling
:
result = CInt(Math.Ceiling(25 / 9))
这两种方法都有所不同。第一个将始终为结果添加+1,而如果有余数,Math.Ceiling
将仅返回下一个整数。
答案 1 :(得分:0)
我想你想要将输出转换到下一个整数如果是,那么试试这个
Dim dbCount As Integer
Dim val, val1 As Integer
Dim intrslt As Integer
Dim dblrslt As Double
val = 20
val1 = 7
intrslt = (val / val1)' output : 3
dblrslt = (val / val1)' output : 2.85
或
使用
Dim dbCount As Double = CInt(imgCount / batSz)
Dim rslt As Double
rslt = CInt((20 / 7)) ' output : 3
rslt = Convert.ToInt32(Int(20 / 7)) ' output :2