在WINCE中的一些VB.NET2005通用方法

本文介绍了多种控件操作方法,包括全角数字转半角、字符串长度计算、事件动态绑定及光标控制等,并详细展示了如何利用API进行WAV播放、文件创建、移动与删除等实用功能。

1.将全角数字转换成半角数字

2.字符串(针对全半角混合字符串)

3.动态给控件追加事件(使用递归调实现全部控件的遍)

4.时间格式(11:12)控件的自动输实现

5.动态控制光TEXTBOX控件中的移
6.使用API函数播放WAV声音.
7.使用API函数实现文件的创建,移动,删除.

1.将全角数字转换成半角数字

Public Function ZenkakuNumToHankakuNum(ByRef strNum As String) As Boolean
        Dim dblValue As Double = 0.0
        ZenkakuNumToHankakuNum = True
        For cnt As Integer = 0 To strNum.Length - 1
            dblValue = Char.GetNumericValue(strNum.Chars(cnt))
            If dblValue < 0 Then
                ZenkakuNumToHankakuNum = False
                Continue For
            End If
            strNum = strNum.Replace(strNum.Chars(cnt), CType(dblValue, Integer))
        Next
End Function

2.字符串(针对全半角混合字符串)

 Public Function TextBoxDataLengthChk(ByVal textBox As TextBox) As Boolean
        Dim strData As String = textBox.Text.Trim()
        Dim cntLength As Integer = 0
        For cnt As Integer = 0 To strData.Length - 1
            '
半角文字、全角文字の長さ計算する
            cntLength = cntLength + System.Text.Encoding.Default.GetByteCount(strData.Chars(cnt))
        Next
        If cntLength > textBox.MaxLength Then
            Return False
        End If
        Return True
    End Function

3.动态给控件追加事件(使用递归调实现全部控件的遍)

Private Sub AddEventToControls(ByVal con As Control)
        Dim subCon As Control
        For Each subCon In con.Controls
            If TypeOf subCon Is Panel Then
                AddEventToControls(subCon)
            End If
            If TypeOf subCon Is TextBox Then
                AddHandler subCon.GotFocus, AddressOf SoftKeyBoardForm_GotFocus
            End If
        Next
    End Sub

4.时间格式(11:12)控件的自动输实现

Protected Sub txtTimeControl_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        Dim textBox As TextBox
        Dim intSelectionStart As Integer = 0
        Dim strTextBox As String = ""
        If TypeOf sender Is TextBox Then
            textBox = CType(sender, TextBox)
            intSelectionStart = textBox.SelectionStart
            strTextBox = textBox.Text
            '
キーの範囲チェック(0-9)
            If e.KeyValue >= 48 And e.KeyValue <= 57 Then
                If intSelectionStart = 2 Then
                    textBox.SelectionStart = 3
                ElseIf textBox.Text.Length = 5 And intSelectionStart < textBox.MaxLength Then
                    textBox.Text = strTextBox.Substring(0, intSelectionStart) & strTextBox.Substring(intSelectionStart + 1, textBox.Text.Length - intSelectionStart - 1)
                    textBox.SelectionStart = intSelectionStart
                End If
            Else
                textBox.SelectionLength = 0
            End If
        End If
    End Sub

5.动态控制光TEXTBOX控件中的移

Public Sub FocusMoveInControl(ByVal moveDirection As String)
        Dim txtTextBox As TextBox
        txtTextBox = CType(GetCurrentControlByIndex(frmCurrentActiveForm, intCurrentControlIndex), TextBox)
        '
左へ移行する
        If moveDirection.Equals("left") Then
            If txtTextBox.SelectionStart > 0 Then
                txtTextBox.SelectionStart = txtTextBox.SelectionStart - 1
            End If
            '
右へ移行する
        ElseIf moveDirection.Equals("right") Then
            If txtTextBox.SelectionStart < txtTextBox.Text.Length Then
                txtTextBox.SelectionStart = txtTextBox.SelectionStart + 1
            End If
        End If
        txtTextBox.Focus()
    End Sub

'根据控件的索引遍得到控件

Private Function GetCurrentControlByIndex(ByVal con As Control, ByVal intControlIndex As Integer) As Control
        Dim control As Control = Nothing
        For Each control In con.Controls
            If intControlIndex = control.TabIndex Then
                conValide = control
                Exit For
            End If
            If TypeOf control Is Panel Then
                GetCurrentControlByIndex(control, intControlIndex)
            End If
        Next
        Return conValide
    End Function

6.使用API函数播放WAV声音.
Private Declare Function WCE_PlaySound Lib "CoreDll.dll" Alias "PlaySound" _
            (ByVal szSound As String, ByVal hMod As IntPtr, ByVal flags As Integer) As Integer
Public Sub PlaySound(ByVal strSoundFile As String)
        Try
            WCE_PlaySound(strSoundFile, 0, 2)
        Catch ex As Exception
            
        End Try
    End Sub

7.使用API函数实现文件的创建,移动,删除.
#Region "常数定义"
    Private GENERIC_READ As Integer = &H80000000
    Private GENERIC_WRITE As Integer = &H40000000
    Private OPEN_EXISTING As Integer = 3
    Private OPEN_NO_EXISTING As Integer = 1
    Private FILE_FLAG_OVERLAPPED As Integer = &H40000000
    Private iMode As Integer = Convert.ToInt32(FILE_FLAG_OVERLAPPED)
#End Region
#Region "STRUCT"
    ' This is the OverLapped structure used by the calls to the Windows API.
    Private Structure OVERLAPPED
        Private Internal As Integer
        Private InternalHigh As Integer
        Private Offset As Integer
        Private OffsetHigh As Integer
        Private hEvent As Integer
    End Structure
#End Region
#Region "API"
    Private Declare Function CreateFile Lib "CoreDll.dll" ( _
        ByVal lpFileName As String, _
        ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, _
        ByVal lpSecurityAttributes As Integer, _
        ByVal dwCreationDisposition As Integer, _
        ByVal dwFlagsAndAttributes As Integer, _
        ByVal hTemplateFile As Integer) As Integer

    Private Declare Function WriteFile Lib "CoreDll.dll" ( _
        ByVal hFile As Integer, ByVal Buffer As Byte(), _
        ByVal nNumberOfBytesToWrite As Integer, _
        ByRef lpNumberOfBytesWritten As Integer, _
        ByRef lpOverlapped As OVERLAPPED) As Integer

    Private Declare Function CloseHandle Lib "CoreDll.dll" ( _
        ByVal Handle As Integer) As Int32

    Private Declare Function MoveFileW Lib "CoreDll.dll" Alias "MoveFile" ( _
        ByVal src As String, ByVal dst As String) As Boolean
    Private Declare Function CeDeleteFile Lib "CoreDll.dll" Alias "DeleteFile" ( _
        ByVal strFileName As String) As Boolean
#End Region
   
    Public Sub CreateFile(ByVal strFileName As String, ByVal bytText() As Byte)
        Dim hFile As Integer = 0
        Dim overLapped1 As OVERLAPPED = New OVERLAPPED()

        Try
            hFile = CreateFile(strFileName, GENERIC_READ Or GENERIC_WRITE, 0, 0, _
                            OPEN_NO_EXISTING, iMode, 0)
            WriteFile(hFile, bytText, bytText.Length, 0, overLapped1)
            CloseHandle(hFile)
        Catch ex As Exception
           
        End Try
    End Sub

   
    Public Sub MoveFile(ByVal strFileNameS As String, ByVal strFileNameE As String)
        Try
            MoveFileW(strFileNameS, strFileNameE)
        Catch ex As Exception
           
        End Try
    End Sub

    Public Sub DeleteFile(ByVal strFileName As String)
        Try
            CeDeleteFile(strFileName)
        Catch ex As Exception
            WriteErrLog("DeleteFile:", ex.Message)
        End Try
    End Sub

随着人类对生命健康需求的不断增长,新药研发面临着前所未有的挑战。传统的药物研发流程通常耗时长达十年以上,耗资数十亿美元,且最终成功率极低,这在制药界被称为“反摩尔定律”困境。近年来,人工智能技术的飞速发展,特别是深度学习和大数据分析的广泛应用,为新药发现带来了革命性的契机。人工智能能够从海量的化学和生物数据中挖掘潜在规律,显著加速药物靶点发现、先导化合物优化等关键环节。在此背景下,本研究旨在设计并实现一个基于人工智能的新药发现辅助系统,以期为传统药物研发流程提供高效的智能化辅助工具,从而有效缩短研发周期并大幅降低研发成本。本研究以Python作为主要开发语言,深度结合PyTorch和TensorFlow两大主流深度学习框架,并集成RDKit化学信息学工具包,构建了一个功能完善的新药发现辅助系统。系统的核心目标是利用先进的人工智能技术辅助新药分子的设计与活性评估。在研究方法上,本文创新性地提出了一种融合多模态数据的新药发现算法。该算法综合处理分子的多种表示形式,包括一维的SMILES序列、二维的分子图结构以及三维的空间构象数据。通过构建多通道神经网络,系统能够有效提取并融合不同模态的特征,从而全面捕捉分子的理化性质与生物学活性之间的复杂非线性关系。 【课程报告内容】 摘要 第1章 绪论 第2章 相关技术与理论 第3章 系统需求分析 第4章 系统总体设计 第5章 系统详细设计与实现 第6章 系统测试与分析 第7章 总结与展望 参考文献 附件-实现指南
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值