vb.net圣经带快捷键,用原装的数据库

vbnet 复制代码
'Imports System.Data.SqlServerCe
Imports System.Text.RegularExpressions
Imports System.Data.OleDb

Public Class Form1
    Dim jiuyue As String() = {"创", "出", "利", "民", "申", "书", "士", "得", "撒上", "撒下", "王上", "王下", "代上", "代下", "拉", "尼", "斯", "伯", "诗", "箴", "传", "歌", "赛", "耶", "哀", "结", "但", "何", "珥", "摩", "俄", "拿", "弥", "鸿", "哈", "番", "该", "亚", "玛"}
    Dim xinyue As String() = {"太", "可", "路", "约", "徒", "罗", "林前", "林后", "加", "弗", "腓", "西", "帖前", "帖后", "提前", "提后", "多", "门", "来", "雅", "彼前", "彼后", "约壹", "约贰", "约叁", "犹", "启"}
    Dim tsl As ToolStripLabel = New ToolStripLabel("按f5全屏,esc退出全屏")

    Dim msjiuyue As MenuStrip = New MenuStrip()
    Dim msxinyue As MenuStrip = New MenuStrip()
    Dim rtb As RichTextBox = New RichTextBox()
    Dim rtb2 As RichTextBox = New RichTextBox()

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        rtb.Dock = DockStyle.Fill
        rtb.Font = New Font("黑体", 70, FontStyle.Bold)
        rtb.BackColor = Color.Black
        rtb.ReadOnly = True

        For i As Integer = 0 To jiuyue.Length - 1
            Dim tsb As ToolStripButton = New ToolStripButton(jiuyue(i))
            AddHandler tsb.Click, AddressOf tsbClick

            If i < 5 Then
                tsb.BackColor = Color.Cyan
            ElseIf i < 17 Then
                tsb.BackColor = Color.Magenta
            ElseIf i < 22 Then
                tsb.BackColor = Color.Yellow
            ElseIf i < 39 Then
                tsb.BackColor = Color.Pink
            End If
            msjiuyue.Items.Add(tsb)
        Next i

        For i As Integer = 0 To xinyue.Length - 1
            Dim tsb As ToolStripButton = New ToolStripButton(xinyue(i))
            AddHandler tsb.Click, AddressOf tsbClick
            If i < 4 Then
                tsb.BackColor = Color.Cyan
            ElseIf i < 5 Then
                tsb.BackColor = Color.Magenta
            ElseIf i < 26 Then
                tsb.BackColor = Color.Yellow
            ElseIf i < 27 Then
                tsb.BackColor = Color.Pink
            End If
            msxinyue.Items.Add(tsb)
        Next i

        msxinyue.Items.Add(tsl)

        Me.WindowState = FormWindowState.Maximized
        Me.Controls.Add(msxinyue)
        Me.Controls.Add(msjiuyue)
        Me.Controls.Add(rtb)
        Me.KeyPreview = True '开启键盘监听
        AddHandler Me.KeyDown, AddressOf f5escClick
    End Sub

    Private Sub tsbClick(sender As Object, e As EventArgs)
        Dim s As String = CType(sender, ToolStripButton).Text
        selecthb(s)
    End Sub

    Private Sub selecthb(ShortName As String)
        Dim s As String = InputBox("输入章数,开始小节,中间用空格分开", "输入章节数,中间用空格间隔", "1 1")

        If s = Nothing Then
            Return
        ElseIf s.Equals("") Then
            Return
        End If

        Dim fenge As String() = s.Split(" ")

        If fenge.Length < 2 Then
            Return
        End If

        If Not IsNumeric(fenge(0).Trim()) Or Not IsNumeric(fenge(1).Trim()) Then
            Return
        End If

        Me.rtb.Text = ""

        Using con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=bibleNosound.dat;Persist Security Info=True;Jet OLEDB:Database Password=pasitoldata")
            Using cmd As OleDbCommand = New OleDbCommand("select * from bible, bibleid where bible.VolumeSN = bibleid.SN and ShortName = @ShortName and ChapterSN = @ChapterSN and VerseSN >= @VerseSN", con)
                cmd.Parameters.AddWithValue("ShortName", ShortName)
                cmd.Parameters.AddWithValue("ChapterSN", fenge(0))
                cmd.Parameters.AddWithValue("VerseSN", fenge(1))
                con.Open()
                Using sdr As OleDbDataReader = cmd.ExecuteReader()
                    Dim i As Integer = 0
                    While sdr.Read()
                        If i Mod 3 = 0 Then
                            Me.rtb.SelectionColor = Color.Cyan
                        ElseIf i Mod 3 = 1 Then
                            Me.rtb.SelectionColor = Color.Magenta
                        Else
                            Me.rtb.SelectionColor = Color.Yellow
                        End If
                        Me.rtb.AppendText(Chr(13) & sdr("ShortName") & ":" & sdr("ChapterSN") & ":" & sdr("VerseSN") & sdr("strjw"))
                        i += 1
                    End While
                End Using
            End Using
        End Using
        Me.rtb.Select(0, 0)
        Me.rtb.Focus()
    End Sub

    Public Sub sql()
        Using con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=bibleNosound.mdb;Persist Security Info=True")
            Using cmd As OleDbCommand = New OleDbCommand("select fullname,shortname,chapterSn,versesn,strjw from bible, bibleid where volumesn = sn", con)
                Using oda As OleDbDataAdapter = New OleDbDataAdapter(cmd)
                    Using dt As DataTable = New DataTable()
                        oda.Fill(dt)
                        Dim dgv As DataGridView = New DataGridView()
                        dgv.Dock = DockStyle.Fill
                        dgv.DataSource = dt
                        Me.Controls.Add(dgv)
                    End Using
                End Using
            End Using
        End Using
    End Sub

    Private Sub f5escClick(sender As Object, e As KeyEventArgs) '实现监听键盘事件
        Dim kc As Keys = e.KeyCode
        If kc = Keys.F5 Then
            Me.msjiuyue.Visible = False
            Me.msxinyue.Visible = False
        ElseIf kc = Keys.Escape Then
            Me.msjiuyue.Visible = True
            Me.msxinyue.Visible = True
        End If
    End Sub

End Class
相关推荐
前端Hardy1 分钟前
HTML&CSS: 实现可爱的冰墩墩
前端·javascript·css·html·css3
weixin_4493108415 分钟前
高效集成:聚水潭采购数据同步到MySQL
android·数据库·mysql
web Rookie31 分钟前
JS类型检测大全:从零基础到高级应用
开发语言·前端·javascript
Au_ust39 分钟前
css:基础
前端·css
帅帅哥的兜兜39 分钟前
css基础:底部固定,导航栏浮动在顶部
前端·css·css3
yi碗汤园42 分钟前
【一文了解】C#基础-集合
开发语言·前端·unity·c#
就是个名称42 分钟前
购物车-多元素组合动画css
前端·css
Cachel wood1 小时前
Github配置ssh key原理及操作步骤
运维·开发语言·数据库·windows·postgresql·ssh·github
standxy1 小时前
如何将钉钉新收款单数据高效集成到MySQL
数据库·mysql·钉钉
编程一生1 小时前
回调数据丢了?
运维·服务器·前端