格式化输出客户端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脚本执行的过程

一、前言JavaScript脚本在页面上的执行顺序问题,一直是个令javascript初学者困惑的问题。接下来我将就这个问题做一比较全面的总结,希望对初学者有所帮助。本文从以下四个方面讲解javasc...
  • xiaobai251206725
  • xiaobai251206725
  • 2010年09月17日 23:14
  • 971

IOS 格式化输出符号与类型转换

1、IOS 格式化输出符号  %@    对象 %d,%i 整数 %u   无符号整形 %f    浮点(双字节) %x,%X  二进制整数 %o  八进制整数 %zi    正整数...
  • u011872945
  • u011872945
  • 2013年11月23日 10:58
  • 2831

【JS】【客户端】JavaScript程序的执行

客户端JavaScript程序的执行 客户端JavaScript程序没有严格的定义,可以说JavaScript程序是由Web页面中所包含的所有JavaScript代码和通过标签的src属性引用的外部...
  • robinjwong
  • robinjwong
  • 2014年11月30日 01:38
  • 1033

mongodb shell 运行js脚本的四种方式

最近,偶尔会有一些比较复杂的mongodb维护任务,需要编写js脚本来处理。以前零零散散看过两本mongodb的教程,但书上都没有仔细讲过如何运行js脚本。就此机会仔细学习一下吧。...
  • wershest
  • wershest
  • 2017年06月07日 12:35
  • 5640

java 格式化输出

常规类型的格式化String类的format()方法用于创建格式化的字符串以及连接多个字符串对象。熟悉C语言的同学应该记得C语言的sprintf()方法,两者有类似之处。format()方法有两种重载...
  • u011625768
  • u011625768
  • 2016年04月06日 00:10
  • 1149

C# 格式化输出

格式化表示的一般格式 { N [ , M ] [ :格式码 ] } N:  指定参数序列中的输出序号,比如{0} , {1}, {2}等。 M: 指定参数输出的最小长度。 如果参数长度小于M,则...
  • fonjames
  • fonjames
  • 2016年10月17日 17:13
  • 2116

c语言笔记-printf()格式化输出详解

% - 0 m.n l或h 格式字符   下面对组成格式说明的各项加以说明:   ①%:表示格式说明的起始符号,不可缺少。   ②-:有-表示左对齐输出,如省略表示右对齐输出。   ③0:有0...
  • qq_36859842
  • qq_36859842
  • 2017年08月04日 23:27
  • 279

MATLAB格式化输出控制

MATLAB格式化输出控制 format 默认格式 format short 5字长定点数 format long 15字长定点数 format short e 5字长浮点数 forma...
  • qq_21904665
  • qq_21904665
  • 2015年07月31日 23:01
  • 1984

java格式化输出当前时间

DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); log.info("开始:" + df.format(new Date(S...
  • Leolu007
  • Leolu007
  • 2016年01月17日 16:22
  • 1652

给beanutils注册转换器

将一个String类型的转化为Date类型的。 ConvertUtils.register(new Converter(){ @Override public Date conve...
  • qq_33665647
  • qq_33665647
  • 2016年08月20日 17:00
  • 811
收藏助手
不良信息举报
您举报文章:格式化输出客户端js脚本的转换器
举报原因:
原因补充:

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