wuxing@name
  • Archives
  • Baby
  • CODING
  • About
wuxing@name
  • Archives
  • Baby
  • CODING
  • About
Category:

程序开发

C++ go Ruby on Rails python 全都不会~

.NET

[转]C#连接Oracle数据库

by Andy 5月 7, 2012

C#连接Oracle数据库的字符串如下:

Data Source=GDBZH;User Id=zhangf;Password=guangy;

需要特别指出的是Data Source这个值是什么,从哪里获取到(后面两个,能在这里看到的,估计都知道意思了吧,后面两个不解析了)。

Data Source:从字面上解释就是数据源,这个数据源是从Oracle的tnsnames.ora文件中去找的。而并非是在系统的“管理工具”下的“数据源(ODBC)”中找。这个tnsnames.ora文件是在Oracle的安装目录下的“network\admin\”下。如我这个例子的GDBZH是这样的:

 
GDBZH =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = GDBZH)
    )
  )
 

这里说明一下:SERVICE_NAME = GDBZH 这个应该是Oracle是数据库的名称。在安装时如果没改的话,一般默认是ORCL。

Continue Reading
5月 7, 2012 0 comment
0 FacebookTwitterPinterestEmail
.NET

[原创]VB.net 通过Google Map API计算路程距离

by Andy 9月 8, 2011

利用Google Directions API (Google Map) http://code.google.com/intl/zh-CN/apis/maps/documentation/directions/
和VB.net 输入目的地(支持中文地址、经纬度等)计算出距离。
如:输入 北京|上海|天津
运行程序 会计算从A地出发依次到北京、上海、天津 三地的总距离,可选择是否包含返回的距离(天津到A地的距离)。
如果需要线路优化 可以参照API 介绍中的 optimize:true。开启后会自动安排路线。

已经在VB.net 2003 通过测试。

做的着急有些地方直接复制的,代码没有优化,有些重复,但不影响最终使用。

'需要以下命名空间
Imports System.web
Imports System.Xml
Imports System.IO

'需要声明的变量
Dim gstrPatch As String = "C:\XXX\map.xml"

    Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
     '判断输入的目的地是否为空。
        If txtROAD_ROUTE.Text = "" Then Exit Sub

        Try

          If MsgBox("路程距离数据会受到网络、关键字的影响,可能与实际距离相差很大,仅供参考。", MsgBoxStyle.YesNo, "系统提示") = MsgBoxResult.No Then Exit Sub
  
          Dim arrROAD As String()
          Dim strWaypoints As String  
          Dim i As Integer = 0
  
          arrROAD = txtROAD_ROUTE.Text.Split("|")
          Dim arrCalc(arrROAD.Length - 1) As String
      '对搜索的目的地编码
          For t As Integer = 0 To arrROAD.Length - 1
              arrROAD(t) = HttpUtility.UrlEncode(arrROAD(t), System.Text.Encoding.UTF8)  
          Next
         
      '编码重组
          For t As Integer = 0 To arrROAD.Length - 2
              If strWaypoints = "" Then
                  strWaypoints = arrROAD(t)
              Else
                  strWaypoints = strWaypoints & "|" & arrROAD(t)
              End If
          Next
         
      '39.049435,121.782503 为出发地 经纬度,可以替换成路名、地名等,注意中文请注意转码。
          Dim strURL As String
          strURL = "<a href="http://maps.google.com/maps/api/directions/xml?origin=39.049435,121.782503&destination">http://maps.google.com/maps/api/directions/xml?origin=39.049435,121.782503&destination</a>=" & arrROAD(arrROAD.Length - 1) & _
                  "&waypoints=" & strWaypoints & _
                  "&sensor=false"
  
          Dim myWebClient As New System.Net.WebClient
          'myWebClient.DownloadFile("<a href="http://maps.google.com/maps/api/directions/xml?origin=39.049435,121.782503&destination">http://maps.google.com/maps/api/directions/xml?origin=39.049435,121.782503&destination</a>=" & strdifang & "&waypoints=&sensor=false", "C:\msdn.xml")
          myWebClient.DownloadFile(strURL, gstrPatch)
  
          Dim xmlDoc As New XmlDocument
          Dim XmlFileName As String = gstrPatch
  
          If File.Exists(XmlFileName) Then
              xmlDoc.Load(XmlFileName)
              Dim nodeList As XmlNodeList = xmlDoc.SelectSingleNode("DirectionsResponse").ChildNodes
              Dim xn1 As XmlNode
              Dim xn2 As XmlNode
              Dim xn3 As XmlNode
                  For Each xn1 In nodeList
                      For Each xn2 In xn1
                          For Each xn3 In xn2
                              If xn3.Name = "distance" Then
                                  arrCalc(i) = xn3.ChildNodes.Item(1).InnerText
                                  i = i + 1
                              End If
                          Next
                      Next
                  Next
          End If
  
          Dim douKM As Double
          Dim strLast As String
  
          If MsgBox("是否计算往返路程?", MsgBoxStyle.YesNo, "系统提示") = MsgBoxResult.Yes Then
              strURL = "<a href="http://maps.google.com/maps/api/directions/xml?origin">http://maps.google.com/maps/api/directions/xml?origin</a>=" & arrROAD(arrROAD.Length - 1) & "&destination=39.049435,121.782503" & _
                       "&sensor=false"
              myWebClient.DownloadFile(strURL, gstrPatch)
              '*计算
  
              Dim xmlDoc2 As New XmlDocument
              Dim XmlFileName2 As String = gstrPatch
  
              If File.Exists(XmlFileName2) Then
                  xmlDoc2.Load(XmlFileName2)
                  Dim nodeList As XmlNodeList = xmlDoc2.SelectSingleNode("DirectionsResponse").ChildNodes
                  Dim xn12 As XmlNode
                  Dim xn22 As XmlNode
                  Dim xn32 As XmlNode
                      For Each xn12 In nodeList
                          For Each xn22 In xn12
                              For Each xn32 In xn22
                                  If xn32.Name = "distance" Then
                                      strLast = xn32.ChildNodes.Item(1).InnerText
                                  End If
                              Next
                          Next
                      Next
              End If
  
              For r As Integer = 0 To arrCalc.Length - 1
                  douKM = douKM + CType(Replace(arrCalc(r), " km", ""), Double)
              Next
  
              douKM = douKM + CType(Replace(strLast, " km", ""), Double)
          Else
              For r As Integer = 0 To arrCalc.Length - 1
                  douKM = douKM + CType(Replace(arrCalc(r), " km", ""), Double)
              Next
          End If
      '显示距离 KM 单位
          txtDISTANCE.Text = douKM

        Catch ex As Exception
            MsgBox("获取距离数据失败。")
        End Try

    End Sub
9月 8, 2011 0 comment
0 FacebookTwitterPinterestEmail
.NET

[原创]VB.net 根据日期取本周第一天 可自定义

by Andy 9月 6, 2011

.net 里面的每周第一天默认是星期日,实在是不符合中国人的行为习惯。
以下函数 可以返回 传入日期所在星期的第一天,可自定义星期的第一天 是星期一、二、三 …  … 日

  Private Function FirstDayOfWeek(ByVal day As DateTime, ByVal weekStarts As DayOfWeek) As DateTime
        Dim d As DateTime = day
        Do While d.DayOfWeek <> weekStarts
            d = d.AddDays(-1)
        Loop
        Return d
    End Function
9月 6, 2011 0 comment
0 FacebookTwitterPinterestEmail
程序开发

SQL Server 自增字段归零

by Andy 8月 1, 2011

假设有一数据库表admin.ROLE,现已在其中多次插入删除数据,使得自增字段当前值混乱。于是可通过下列语句,重新设定自增字段的起始值。但要注意在数据库表中不能存在相同的自增字段值。

DBCC CHECKIDENT (‘admin.ROLE’, RESEED, 0)

8月 1, 2011 0 comment
0 FacebookTwitterPinterestEmail
程序开发

VB.net DT distinct 功能

by Andy 7月 11, 2011
'*----------------------------------------------------------------
'*
'*         函数名称:   VB.net DT distinct 功能
'*         摘    要:   用法 dt = SelectDistinct("新DT名", 需要过滤的DT, "字段名")
'*
'*----------------------------------------------------------------

#Region "DT 临时表 去重复 DT 内 distinct -停止使用"

    Public Function SelectDistinct(ByVal TableName As String, _
                                ByVal SourceTable As DataTable, _
                                ByVal FieldName As String) As DataTable
        Dim dt As New DataTable(TableName)
        dt.Columns.Add(FieldName, SourceTable.Columns(FieldName).DataType)
        Dim dr As DataRow, LastValue As Object
        For Each dr In SourceTable.Select("", FieldName)
            If LastValue Is Nothing OrElse Not ColumnEqual(LastValue, dr(FieldName)) Then
                LastValue = dr(FieldName)
                dt.Rows.Add(New Object() {LastValue})
            End If
        Next
        'If Not ds Is Nothing Then ds.Tables.Add(dt)
        Return dt
    End Function

    Private Function ColumnEqual(ByVal A As Object, ByVal B As Object) As Boolean
        '
        ' Compares two values to determine if they are equal. Also compares DBNULL.Value.
        '
        ' NOTE: If your DataTable contains object fields, you must extend this
        ' function to handle the fields in a meaningful way if you intend to group on them.
        '
        If A Is DBNull.Value And B Is DBNull.Value Then Return True ' Both are DBNull.Value.
        If A Is DBNull.Value Or B Is DBNull.Value Then Return False ' Only one is DBNull.Value.
        Return A = B                                                ' Value type standard comparison
    End Function

#End Region
7月 11, 2011 0 comment
0 FacebookTwitterPinterestEmail
程序开发

[原创]VB.net 写入修改Host

by Andy 7月 4, 2011
    '提前调用
    Imports System.IO
    Imports System.ServiceProcess
     '窗体内 放置 一个RichTextBox 命名为 rtbHost
		
    Private Function Write_Host(ByVal strIP as string,ByVal strHost as string) As String
        Dim strReturn As String = "OK"
        Try
            '读数据
            Dim operachina As String
            Dim strFileName As String

            strFileName = Environ$("SystemRoot") & "\System32\drivers\etc\hosts"

            Dim SR As New StreamReader(strFileName)
            rtbHost.Text = SR.ReadToEnd

            SR.Close()

            If rtbHost.Find(strHost) < 0 Then

                operachina = strIP + "   " + strHost + vbCrLf

                '写数据
                rtbHost.AppendText(vbCrLf + operachina)

                Dim SW As New StreamWriter(strFileName)
                SW.Write(rtbHost.Text)
                SW.Close()

                '重启DNS服务
                Dim service As New ServiceController

                service.ServiceName = "Dnscache"

                If service.Status = ServiceControllerStatus.Running Then

                    service.Stop()
                    service.WaitForStatus(ServiceProcess.ServiceControllerStatus.Stopped)
                    service.Start()
                    service.WaitForStatus(ServiceProcess.ServiceControllerStatus.Running)
                ElseIf service.Status = ServiceControllerStatus.Stopped Then
                    service.Start()
                    service.WaitForStatus(ServiceProcess.ServiceControllerStatus.Running)
                End If

            End If

        Catch ex As Exception
            strReturn = ex.Message
            Throw
        End Try
        Return strReturn
    End Function
    
    '使用方法
     If Write_Host("192.168.1.100","test.wuxing.name") <> "OK" Then MsgBox("DNS解析错误,可能无法访问。")
     System.Diagnostics.Process.Start("IEXPLORE.EXE", "http://test.wuxing.name/")
7月 4, 2011 0 comment
0 FacebookTwitterPinterestEmail
程序开发

[原创]PointFar Spread 使用 RadioButton MultiOption 单选

by Andy 4月 28, 2011

想用 PointFar Spread 的 RadioButton MultiOption 进行单选,但是自带的 Spread Designer选择 cell style 为 MultiOption 后没有任何效果,没有checkbox 好用。只好采用代码的方式解决了。

       '1.将以下代码 放入 Form Load 或其他事件中
        With Me.spList4.ActiveSheet
            Dim multiType As New FarPoint.Win.Spread.CellType.MultiOptionCellType
            multiType.Items = New String() {" "}
            For i As Integer = 0 To .RowCount - 1
                    .Cells(i, 0).CellType = multiType
                If i = 0 Then
		'选中第一行,第一列的 0为选中 1为非选
                    .Cells(0, 0).Value = 0
                End If
            Next
        End With
     
   '2.然后加入 以下事件代码 实现单选
    Private Sub spList4_LeaveCell(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.LeaveCellEventArgs) Handles spList4.LeaveCell
        Me.spList4.ActiveSheet.Cells(e.Row, 0).Value = 1
        Me.spList4.ActiveSheet.Cells(e.NewRow, 0).Value = 0
    End Sub
4月 28, 2011 0 comment
0 FacebookTwitterPinterestEmail
程序开发

[原创]用户控件 IP文本框 VB.net

by Andy 4月 19, 2011

vb.net 的textbox 没有 mask 特地制作一个 以备使用。
源码打包 MyIPBox 附带实例。

 
Public Class IpBox Inherits System.Windows.Forms.UserControl #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'UserControl overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents textBox3 As System.Windows.Forms.TextBox Friend WithEvents label3 As System.Windows.Forms.Label Friend WithEvents textBox4 As System.Windows.Forms.TextBox Friend WithEvents label1 As System.Windows.Forms.Label Friend WithEvents textBox1 As System.Windows.Forms.TextBox Friend WithEvents label2 As System.Windows.Forms.Label Friend WithEvents textBox2 As System.Windows.Forms.TextBox <system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel Me.textBox3 = New System.Windows.Forms.TextBox Me.label3 = New System.Windows.Forms.Label Me.textBox4 = New System.Windows.Forms.TextBox Me.label1 = New System.Windows.Forms.Label Me.textBox1 = New System.Windows.Forms.TextBox Me.label2 = New System.Windows.Forms.Label Me.textBox2 = New System.Windows.Forms.TextBox Me.Panel1.SuspendLayout() Me.SuspendLayout() ' 'Panel1 ' Me.Panel1.BackColor = System.Drawing.SystemColors.Window Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Panel1.Controls.Add(Me.textBox3) Me.Panel1.Controls.Add(Me.label3) Me.Panel1.Controls.Add(Me.textBox4) Me.Panel1.Controls.Add(Me.label1) Me.Panel1.Controls.Add(Me.textBox1) Me.Panel1.Controls.Add(Me.label2) Me.Panel1.Controls.Add(Me.textBox2) Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill Me.Panel1.Location = New System.Drawing.Point(0, 0) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(118, 18) Me.Panel1.TabIndex = 0 ' 'textBox3 ' Me.textBox3.BorderStyle = System.Windows.Forms.BorderStyle.None Me.textBox3.Location = New System.Drawing.Point(59, -1) Me.textBox3.Name = "textBox3" Me.textBox3.Size = New System.Drawing.Size(24, 14) Me.textBox3.TabIndex = 11 Me.textBox3.Text = "" Me.textBox3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center ' 'label3 ' Me.label3.BackColor = System.Drawing.Color.Transparent Me.label3.Font = New System.Drawing.Font("Arial", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.label3.Location = New System.Drawing.Point(83, 1) Me.label3.Name = "label3" Me.label3.Size = New System.Drawing.Size(4, 14) Me.label3.TabIndex = 12 Me.label3.Text = "." Me.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'textBox4 ' Me.textBox4.BorderStyle = System.Windows.Forms.BorderStyle.None Me.textBox4.Location = New System.Drawing.Point(87, -1) Me.textBox4.Name = "textBox4" Me.textBox4.Size = New System.Drawing.Size(24, 14) Me.textBox4.TabIndex = 13 Me.textBox4.Text = "" Me.textBox4.TextAlign = System.Windows.Forms.HorizontalAlignment.Center ' 'label1 ' Me.label1.BackColor = System.Drawing.Color.Transparent Me.label1.Font = New System.Drawing.Font("Arial", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.label1.Location = New System.Drawing.Point(27, 3) Me.label1.Name = "label1" Me.label1.Size = New System.Drawing.Size(4, 10) Me.label1.TabIndex = 8 Me.label1.Text = "." Me.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'textBox1 ' Me.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None Me.textBox1.Location = New System.Drawing.Point(3, -1) Me.textBox1.Name = "textBox1" Me.textBox1.Size = New System.Drawing.Size(24, 14) Me.textBox1.TabIndex = 7 Me.textBox1.Text = "" Me.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center ' 'label2 ' Me.label2.BackColor = System.Drawing.Color.Transparent Me.label2.Font = New System.Drawing.Font("Arial", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.label2.Location = New System.Drawing.Point(55, 1) Me.label2.Name = "label2" Me.label2.Size = New System.Drawing.Size(4, 14) Me.label2.TabIndex = 10 Me.label2.Text = "." Me.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'textBox2 ' Me.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None Me.textBox2.Location = New System.Drawing.Point(31, -1) Me.textBox2.Name = "textBox2" Me.textBox2.Size = New System.Drawing.Size(24, 14) Me.textBox2.TabIndex = 9 Me.textBox2.Text = "" Me.textBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center ' 'IpBox ' Me.Controls.Add(Me.Panel1) Me.Name = "IpBox" Me.Size = New System.Drawing.Size(118, 18) Me.Panel1.ResumeLayout(False) Me.ResumeLayout(False)</system.diagnostics.debuggerstepthrough()> End Sub #End Region Public strIP As String Public Property IPAddress() As String Get strIP = "" strIP += IIf(textBox1.Text.Trim() <&gt; "", textBox1.Text.Trim(), "0") strIP += "." strIP += IIf(textBox2.Text.Trim() <&gt; "", textBox2.Text.Trim(), "0") strIP += "." strIP += IIf(textBox3.Text.Trim() <&gt; "", textBox3.Text.Trim(), "0") strIP += "." strIP += IIf(textBox4.Text.Trim() <&gt; "", textBox4.Text.Trim(), "0") Return strIP End Get Set(ByVal Value As String) strIP = Value Dim arrIP As String() = strIP.Split(".") If arrIP.Length &gt; 0 Then Try Value = Convert.ToInt32(arrIP(0).Trim) If Value < 0 Then textBox1.Text = "0" ElseIf Value &gt; "255" Then textBox1.Text = "255" Else textBox1.Text = Value.ToString End If Catch ex As Exception textBox1.Text = "0" Finally textBox1.Text = "0" End Try End If If arrIP.Length &gt; 1 Then Try Value = Convert.ToInt32(arrIP(1).Trim) If Value < 0 Then textBox2.Text = "0" ElseIf Value &gt; "255" Then textBox2.Text = "255" Else textBox2.Text = Value.ToString End If Catch ex As Exception textBox2.Text = "0" Finally textBox2.Text = "0" End Try End If If arrIP.Length &gt; 2 Then Try Value = Convert.ToInt32(arrIP(2).Trim) If Value < 0 Then textBox3.Text = "0" ElseIf Value &gt; "255" Then textBox3.Text = "255" Else textBox3.Text = Value.ToString End If Catch ex As Exception textBox3.Text = "0" Finally textBox3.Text = "0" End Try End If If arrIP.Length &gt; 3 Then Try Value = Convert.ToInt32(arrIP(3).Trim) If Value < 0 Then textBox4.Text = "0" ElseIf Value &gt; "255" Then textBox4.Text = "255" Else textBox4.Text = Value.ToString End If Catch ex As Exception textBox4.Text = "0" Finally textBox4.Text = "0" End Try End If End Set End Property Private Sub textBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textBox1.TextChanged _ , textBox2.TextChanged _ , textBox3.TextChanged _ , textBox4.TextChanged If sender.Text.Trim <&gt; "" Then Dim val As Integer = Convert.ToInt32(sender.Text.Trim) If val < 0 Then sender.Text = "0" ElseIf val &gt; 255 Then sender.Text = "255" sender.SelectionStart = sender.TextLength End If End If End Sub Private Sub textBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox1.KeyDown If e.KeyCode = Keys.Right And textBox1.SelectionStart = textBox1.TextLength Then textBox2.Focus() textBox2.SelectAll() End If End Sub Private Sub textBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox2.KeyDown If textBox2.Text.Trim = "" And e.KeyCode = Keys.Back Then textBox1.Focus() textBox1.SelectionStart = textBox1.Text.Length End If If e.KeyCode = Keys.Right And textBox2.SelectionStart = textBox2.TextLength Then textBox3.Focus() textBox3.SelectAll() ElseIf e.KeyCode = Keys.Left And textBox2.SelectionStart = 0 Then textBox1.Focus() textBox1.SelectAll() End If End Sub Private Sub textBox3_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox3.KeyDown If textBox3.Text.Trim = "" And e.KeyCode = Keys.Back Then textBox2.Focus() textBox2.SelectionStart = textBox2.Text.Length End If If e.KeyCode = Keys.Right And textBox3.SelectionStart = textBox3.TextLength Then textBox4.Focus() textBox4.SelectAll() ElseIf e.KeyCode = Keys.Left And textBox3.SelectionStart = 0 Then textBox2.Focus() textBox2.SelectAll() End If End Sub Private Sub textBox4_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox4.KeyDown If textBox4.Text.Trim = "" And e.KeyCode = Keys.Back Then textBox3.Focus() textBox3.SelectionStart = textBox3.Text.Length End If If e.KeyCode = Keys.Left And textBox4.SelectionStart = 0 Then textBox3.Focus() textBox3.SelectAll() End If End Sub Private Sub textBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textBox1.KeyPress If Char.IsControl(e.KeyChar) Then Else If Not Char.IsDigit(e.KeyChar) Then e.Handled = True End If End If If e.KeyChar = "." Then textBox2.Focus() textBox2.SelectAll() End If End Sub Private Sub textBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textBox2.KeyPress If Char.IsControl(e.KeyChar) Then Else If Not Char.IsDigit(e.KeyChar) Then e.Handled = True End If End If If e.KeyChar = "." Then textBox3.Focus() textBox3.SelectAll() End If End Sub Private Sub textBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textBox3.KeyPress If Char.IsControl(e.KeyChar) Then Else If Not Char.IsDigit(e.KeyChar) Then e.Handled = True End If End If If e.KeyChar = "." Then textBox4.Focus() textBox4.SelectAll() End If End Sub Private Sub textBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textBox4.KeyPress If Char.IsControl(e.KeyChar) Then Else If Not Char.IsDigit(e.KeyChar) Then e.Handled = True End If End If End Sub Private Sub IpBox_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged Dim nTextBoxWidth As Integer = (Me.Width - 3 * label1.Width) / 4 textBox1.Location = New Point(0, 2) textBox1.Width = nTextBoxWidth textBox1.Height = Me.Height label1.Left = textBox1.Right label1.Top = 0 label1.Width = label1.Width label1.Height = Me.Height - 4 textBox2.Left = label1.Right textBox2.Top = 2 textBox2.Width = nTextBoxWidth textBox2.Height = Me.Height label2.Left = textBox2.Right label2.Top = 0 label2.Width = label1.Width label2.Height = Me.Height - 4 textBox3.Left = label2.Right textBox3.Top = 2 textBox3.Width = nTextBoxWidth textBox3.Height = Me.Height label3.Left = textBox3.Right label3.Top = 0 label3.Width = label1.Width label3.Height = Me.Height - 4 textBox4.Left = label3.Right textBox4.Top = 2 textBox4.Width = nTextBoxWidth textBox4.Height = Me.Height - 4 End Sub End Class
4月 19, 2011 0 comment
0 FacebookTwitterPinterestEmail
  • 1
  • 2
  • 3
  • 4
  • 5

About Me

About Me

Writer & Reader

Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed.

Recent Posts

  • Gunicorn FastAPI 宝塔Linux 部署

    8月 26, 2021
  • DeepL机器翻译的力量

    7月 7, 2020
  • net Core Rest Api 调用

    7月 7, 2020
  • Oracle EM 安装 修复

    5月 15, 2020
  • wpf c# login and Upgrade

    12月 6, 2019
  • Facebook
  • Twitter
  • Instagram
  • Pinterest
  • Tumblr
  • Youtube
  • Bloglovin
  • Snapchat

@2019 - All Right Reserved. Designed and Developed by PenciDesign


Back To Top