格式化输出客户端js脚本的转换器

原创 2004年09月05日 10:01:00

可以encode和decode双向转换,支持复制,粘贴

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写处置以清理组件列表。
    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

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意:以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents btnFromClient As System.Windows.Forms.Button
    Friend WithEvents btnToClient As System.Windows.Forms.Button
    Friend WithEvents btnSelectAll As System.Windows.Forms.Button
    Friend WithEvents btnCopy As System.Windows.Forms.Button
    Friend WithEvents btnPaste As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Panel1 = New System.Windows.Forms.Panel()
        Me.btnFromClient = New System.Windows.Forms.Button()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.btnToClient = New System.Windows.Forms.Button()
        Me.btnSelectAll = New System.Windows.Forms.Button()
        Me.btnCopy = New System.Windows.Forms.Button()
        Me.Panel2 = New System.Windows.Forms.Panel()
        Me.RichTextBox1 = New System.Windows.Forms.RichTextBox()
        Me.btnPaste = New System.Windows.Forms.Button()
        Me.Panel1.SuspendLayout()
        Me.Panel2.SuspendLayout()
        Me.SuspendLayout()
        '
        'Panel1
        '
        Me.Panel1.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnFromClient, Me.Label1, Me.btnToClient, Me.btnSelectAll, Me.btnCopy, Me.btnPaste})
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Top
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(768, 56)
        Me.Panel1.TabIndex = 1
        '
        'btnFromClient
        '
        Me.btnFromClient.Location = New System.Drawing.Point(96, 8)
        Me.btnFromClient.Name = "btnFromClient"
        Me.btnFromClient.Size = New System.Drawing.Size(80, 40)
        Me.btnFromClient.TabIndex = 1
        Me.btnFromClient.Text = "Encode"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(496, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(224, 32)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "使用说明:将客户端javascript脚本转换为vb.net中的预输出,双击左键转换"
        '
        'btnToClient
        '
        Me.btnToClient.Location = New System.Drawing.Point(376, 8)
        Me.btnToClient.Name = "btnToClient"
        Me.btnToClient.Size = New System.Drawing.Size(88, 40)
        Me.btnToClient.TabIndex = 1
        Me.btnToClient.Text = "Decode"
        '
        'btnSelectAll
        '
        Me.btnSelectAll.Location = New System.Drawing.Point(192, 16)
        Me.btnSelectAll.Name = "btnSelectAll"
        Me.btnSelectAll.Size = New System.Drawing.Size(72, 24)
        Me.btnSelectAll.TabIndex = 1
        Me.btnSelectAll.Text = "SelectAll"
        '
        'btnCopy
        '
        Me.btnCopy.Location = New System.Drawing.Point(280, 16)
        Me.btnCopy.Name = "btnCopy"
        Me.btnCopy.Size = New System.Drawing.Size(72, 24)
        Me.btnCopy.TabIndex = 1
        Me.btnCopy.Text = "Copy"
        '
        'Panel2
        '
        Me.Panel2.Controls.AddRange(New System.Windows.Forms.Control() {Me.RichTextBox1})
        Me.Panel2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Panel2.Location = New System.Drawing.Point(0, 56)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(768, 406)
        Me.Panel2.TabIndex = 2
        '
        'RichTextBox1
        '
        Me.RichTextBox1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.RichTextBox1.Name = "RichTextBox1"
        Me.RichTextBox1.Size = New System.Drawing.Size(768, 406)
        Me.RichTextBox1.TabIndex = 1
        Me.RichTextBox1.Text = "使用说明:将客户端javascript脚本转换为vb.net中的预输出,双击左键转换"
        '
        'btnPaste
        '
        Me.btnPaste.Location = New System.Drawing.Point(16, 16)
        Me.btnPaste.Name = "btnPaste"
        Me.btnPaste.Size = New System.Drawing.Size(64, 24)
        Me.btnPaste.TabIndex = 1
        Me.btnPaste.Text = "Paste"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(768, 462)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Panel2, Me.Panel1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.Panel1.ResumeLayout(False)
        Me.Panel2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

 

    Private Sub RichTextBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If e.Clicks = 2 And e.Button = MouseButtons.Left Then
            Dim s() As String = Me.RichTextBox1.Lines
            Dim src As String
            Dim dst As String = "Dim s as String="""" & vbCrLf & _ " & vbCrLf
            Dim i As Integer
            For i = 0 To s.Length - 2
                src = s(i)
                dst &= (vbTab & vbTab & vbTab & Chr(34) & src.Replace(Chr(34).ToString, (Chr(34) & Chr(34)).ToString) & Chr(34) & " & vbCrLf & _ ") & vbCrLf
            Next
            src = s(i)
            dst &= (vbTab & vbTab & vbTab & Chr(34) & src.Replace(Chr(34).ToString, (Chr(34) & Chr(34)).ToString) & Chr(34) & " & vbCrLf  ") & vbCrLf

            Me.RichTextBox1.Text = dst

        ElseIf e.Clicks = 2 And e.Button = MouseButtons.Right Then
            Me.RichTextBox1.Clear()
            Me.RichTextBox1.AppendText("使用说明:将客户端javascript脚本转换为vb.net中的预输出,双击左键转换")
        End If


    End Sub

    Private Sub btnFromClient_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFromClient.Click
        Dim s() As String = Me.RichTextBox1.Lines
        Dim src As String
        Dim dst As String = "Dim s as String="""" & vbCrLf & _ " & vbCrLf
        Dim i As Integer
        For i = 0 To s.Length - 1
            src = s(i)
            dst &= (vbTab & vbTab & vbTab & Chr(34) & src.Replace(Chr(34).ToString, (Chr(34) & Chr(34)).ToString) & Chr(34) & " & vbCrLf & _ ") & vbCrLf
        Next
        If dst.Length > 5 Then
            dst = dst.Remove(dst.Length - 6, 6)
        End If
        Me.RichTextBox1.Text = dst

    End Sub

    Private Sub btnToClient_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnToClient.Click
        Dim s() As String = Me.RichTextBox1.Lines
        Dim src As String
        Dim dst As String = ""
        Dim i As Integer
        For i = 1 To s.Length - 1
            src = s(i)
            If src <> "" Then
                src = src.Remove(0, src.IndexOf("""") + 1)
                src = src.Remove(src.LastIndexOf(""" & vbCrLf"), src.Length - src.LastIndexOf(""" & vbCrLf"))
                src = src.Replace((Chr(34) & Chr(34)).ToString, Chr(34).ToString)
                dst &= (src & vbCrLf)
            End If
        Next
        If dst.Length > 5 Then
            dst = dst.Remove(dst.Length - 2, 2)
        End If
        Me.RichTextBox1.Text = dst


    End Sub

    Private Sub btnSelectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectAll.Click
        Me.RichTextBox1.SelectAll()
    End Sub


    Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy.Click
        Me.RichTextBox1.Copy()
    End Sub

    Private Sub btnPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPaste.Click
        Me.RichTextBox1.Clear()
        Me.RichTextBox1.Paste()
    End Sub
End Class

JS关于Date函数的格式化输出

(new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423   (new Date()).Format("yyyy...
  • hl582567508
  • hl582567508
  • 2016年10月04日 21:48
  • 541

js格式化xml字符串

无论是在输入xml字符串还是显示xml字符串,都不可避免的判断xml的正确性。 前台js...
  • llhhyy1989
  • llhhyy1989
  • 2014年05月31日 07:32
  • 4436

《懒人Shell脚本》之二——语料库的格式化输出

1、引言在进行自然语言处理(NLP)处理的时候,基本的操作无外乎分词、分类、聚类、命名实体识别、规则过滤、摘要提取、关键字提取、词性标注、拼音标注等。 分类通用的做法就是根据提供的语言库自学习识别成...
  • wojiushiwo987
  • wojiushiwo987
  • 2016年03月04日 22:56
  • 2182

MySQL命令行格式化输出

MySQL的客户端命令行工具,有很多方便使用者的特性,某些方面甚至可以说比Oracle的sqlplus更加人性化。当然从整体来说,还是sqlplus更加方便些,这么说或许是我对sqlplus更加熟悉吧...
  • orichisonic
  • orichisonic
  • 2015年08月05日 17:55
  • 3441

shell实例浅谈之九格式化输出大数字

一、问题       格式化输出大数字,使得输出结果更清晰地看出数字的数量级。默认用逗号(可用-d指定整数的分隔符)分隔整数部分,用点号(可用-t指定整数与小数的分隔符)分隔整数与小数部分。如1...
  • tian_110
  • tian_110
  • 2015年01月04日 22:16
  • 647

JavaScript客户端脚本编程

1.编写程序在页面上完成产生100道两位数字的加减运算题,并统计正确率。 2.编写程序实现注册页面中用户名(要求其中只含有字母)、密码(要求长队在6和20之间且只可为字母、数字)的验证,如果不合要求给...
  • martinue
  • martinue
  • 2016年06月16日 18:02
  • 665

Js获取当前日期时间及格式化操作

原文地址:http://www.cnblogs.com/qinpengming/archive/2012/12/03/2800002.html var myDate = new Da...
  • zhangtao_who
  • zhangtao_who
  • 2016年12月27日 16:22
  • 346

shell实例浅谈之九格式化输出大数字

一、问题        输入日期格式字符串“month-day-year”,仅将month设置成三个字母显示,第一个字母大写第二到三个字母小写(判断day和year基本相似,此处暂不处理)。 ...
  • taiyang1987912
  • taiyang1987912
  • 2014年10月20日 16:33
  • 2427

JS字符串格式化

http://my.oschina.net/looly/blog/301362 摘要 在Java中我们可以使用String.format()格式化文本来避免丑陋的各种拼接字符串,而在Java...
  • dszgf5717
  • dszgf5717
  • 2016年05月04日 14:58
  • 4353

将JSON对象格式化输出(上篇)

UPDATE:经公子大大提醒,使用JSON API就可以做到下面的效果。 (这后面的内容不用看了) 最近在使用Node.js开发项目,由于JavaScript内置了对JSON的支持,自然而然想...
  • asd131531
  • asd131531
  • 2015年01月05日 21:46
  • 5049
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:格式化输出客户端js脚本的转换器
举报原因:
原因补充:

(最多只允许输入30个字)