Results 1 to 33 of 33

Thread: Convert string to VB6 code,Maximum number of characters per line

  1. #1

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Convert string to VB6 code,Maximum number of characters per line

    Convert string to VB6 code,Maximum number of characters per line
    ----------------------
    how to intercept a string of a specified length by vb6?
    Stringbuilder is a good idea,but i want to use :
    a=a & "b"
    a=a & "c"
    a=
    or
    dim Arr()
    redim arr(3)
    arr(0)="*****************************"
    arr(1)="adfasfadfasdf"

    In VB6 IDE, each line of characters cannot be too long. Is there any way to intercept a string of a specified length and concatenate multiple lines?
    For example, double quotes need to occupy 2 characters, and carriage returns need to occupy 14 characters

    Dim a
    a = "abc""4d" & vbCrLf & "22"

    like this vb code ,JsCode =**
    str from json2.js( or text file)

    Code:
    Function StrToVBcodeArrMax(StrA As String, VarName As String, Optional spacesCount As Long = 4, Optional LineMaxLen As Long = 1023)
    '    Dim Sarr(2) As String
    '    Sarr(0) = "aaaaaaa"
    '    Sarr(1) = "bbbbbbb"
    '    Sarr(2) = "cccccc"
    
        'Len2,Other character length '其他字符长度
        'LenA,Length without array index '不含数组索引的长度
        
    Dim Code As String, LenA As Long, CutLen As Long, Len2 As Long, LenSTR As Long
        Dim TempS As String, Start As Long, BT() As Byte, TxtSpace As Long
        Dim Str As String, VarLen As Long
        Dim CodeArr() As String
        Dim CuteMax As Long, ID As Long, ArrUb As Long
        ArrUb = 1000
        ReDim CodeArr(-1 To ArrUb)
        Str = StrA
        Str = Replace(Str, vbCrLf, "%%vbcrlf%")
        Str = Replace(Str, vbCr, vbCrLf)
        Str = Replace(Str, vbLf, vbCrLf)
        Str = Replace(Str, "%%vbcrlf%", vbCrLf)
        
        Str = Replace(Str, Chr(34), Chr(34) & Chr(34))
        BT = StrConv(VarName, vbFromUnicode)
        VarLen = UBound(BT) + 1 'Len(VarName)
        LenSTR = Len(Str)
    
        Len2 = VarLen + 7
        LenA = spacesCount + Len2
        Start = 1
        ID = 0
        '===============
    DoCutMaxLine:
    '提取最长段处理:
        CuteMax = LineMaxLen - LenA - Len(ID & "")
        CutLen = CuteMax
        Dim TempS0 As String
        
        Do While CutLen > 1
        TempS = Mid(Str, Start, CutLen)
        TempS0 = TempS
     
        If InStr(TempS, vbCrLf) > 0 Then TempS = Replace(TempS, vbCrLf, Chr(34) & " & VBCRLF & " & Chr(34))
        If InStr(TempS, Chr(9)) > 0 Then TempS = Replace(TempS, Chr(9), Chr(34) & " & Chr(9) & " & Chr(34))
        
        BT = StrConv(TempS, vbFromUnicode)
        TxtSpace = UBound(BT) + 1
        If TxtSpace <= CuteMax Then
            If (Right(TempS0, 1) = Chr(34) And Right(TempS0, 2) <> Chr(34) & Chr(34)) Then
                'The double quotes are cut
                 '双引号被切开了
            ElseIf Right(TempS0, 1) = vbCr Then
                'Carriage return is cut open
                '回车符被切开了
            Else
                CodeArr(ID) = String(spacesCount, " ") & VarName & "(" & ID & ") = """ & TempS & Chr(34)
                Debug.Print "第" & ID & "段,字符个数=" & CutLen & ",位置" & Start & ",字符量" & LenSTR
                 ID = ID + 1
                 If ID > ArrUb Then
                    ArrUb = ArrUb * 1.5
                    ReDim Preserve CodeArr(-1 To ArrUb)
                 End If
                
                Exit Do
            End If
        End If
        CutLen = CutLen - 1
        Loop
        
        If CutLen = 0 Then
            MsgBox "CutLen=0"
            GoTo Doend
        End If
        Start = Start + CutLen
            If Start < LenSTR Then
                GoTo DoCutMaxLine
            Else
                GoTo Doend
            End If
    Doend:
    CodeArr(-1) = String(spacesCount, " ") & "Dim " & VarName & "(" & ID - 1 & ") As String"
    CodeArr(ID) = String(spacesCount, " ") & "'Msgbox Join(" & VarName & ","""")"
    ReDim Preserve CodeArr(-1 To ID)
    Code = Join(CodeArr, vbCrLf)
    StrToVBcodeArrMax = Code
    End Function
    Code:
    Dim Js As ScriptControl: Set Js = New ScriptControl
    'Dim Js As Object: Set Js = CreateObject("ScriptControl")
    Dim JsCode As String, JsonStr As String
    'json1.js at 2005,For Support JSON.stringify in vb6
    
    JsCode = "var JSON=function(){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','""':'\\""','\\':'\\\\'},s={'boolean':function(x){return String(x)},number:function(x){return isFinite(x)?String(x):'null'},string:function(x){if(/[""\\\x00-\x1f]/.test(x)){x=x.replace(/([\x00-\x1f\\""])/g,function(a,b){var c=m[b];if(c){return c}c=b.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16)})}return'""'+x+'""'},object:function(x){if(x){var a=[],b,f,i,l,v;if(x instanceof Array){a[0]='[';l=x.length;for(i=0;i<l;i+=1){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=','}a[a.length]=v;b=true}}}a[a.length]=']'}else if(x instanceof Object){a[0]='{';for(i in x){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=','}a.push(s.string(i),':',v);b=true}}}a[a.length]='}'}else{return}return a.join('')}return'null'}};return{"
    JsCode = JsCode & "copyright: '(c)2005 JSON.org',license:'http://www.crockford.com/JSON/license.html',stringify:function(v){var f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){return v}}return null},parse:function(text){try{return!(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/""(\\.|[^""\\])*""/g,'')))&&eval('('+text+')')}catch(e){return false}}}}();"
    JsCode = JsCode & "var TempStr=''; function SetTempStr(Str){TempStr=Str;};"
    Js.Language = "Javascript"
    Js.AddCode JsCode
    
    JsonStr = "{""key1"":""●●◆◆"",""key2"":""abc"",""arr1"":[{""c"":""aa"",""d"":""bb""},{""e"":""dd""}]}"
    
    
    'Convert string to Json object
    Js.AddCode "var JsonObj=" & JsonStr
    
    MsgBox Js.Eval("JsonObj.key1")
     Js.Eval ("JsonObj.key3='str3'")
    
    'Convert JSON object to string
    MsgBox Js.Eval("JSON.stringify(JsonObj)")
    
    Js.Run "SetTempStr", "abc" & vbCrLf & "123"
     Js.Eval ("JsonObj.key1=TempStr")
     MsgBox Js.Eval("JsonObj.key1")
    MsgBox Js.Eval("JSON.stringify(JsonObj)")
    Last edited by xiaoyao; May 16th, 2021 at 07:09 AM.

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    3,232

    Re: how to intercept a string of a specified length by vb6?

    I'm not sure what you are asking, but I recently posted a script to turn multiline text into String constant that may be close to what you want.

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,543

    Re: how to intercept a string of a specified length by vb6?

    I also am not sure what you are asking, there are the len(), Mid$() and Instr() functions all of which are related to string length and positions and you showed you already know how to concatenate strings multiline or otherwise so what is it you are actually asking?

  4. #4

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: how to intercept a string of a specified length by vb6?

    Quote Originally Posted by DataMiser View Post
    I also am not sure what you are asking, there are the len(), Mid$() and Instr() functions all of which are related to string length and positions and you showed you already know how to concatenate strings multiline or otherwise so what is it you are actually asking?
    How to precisely control how many characters should be taken in each line?
    In the case of different variable names, accurately control the length of each line to the maximum

    a = a & "***"
    abc = abc & "***"
    abc = abc & """a" & vbcrlf & "***"

    sz(0) = "aaaa***"
    sz(11) = "aaaa***"

  5. #5
    PowerPoster
    Join Date
    Feb 2017
    Posts
    3,232

    Re: how to intercept a string of a specified length by vb6?

    VB6 has a line limit of 1024 characters, not sure if that is what you are asking.

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,543

    Re: how to intercept a string of a specified length by vb6?

    Yeah I still do not know what is being asked.
    If you are reading the data line by line then you can use len() to see how long it is. You can use Left$() or Mid$() to only read part of that data.
    You can use binary methods and read the data in chunks of whatever size you want but again the question is unclear.

  7. #7
    PowerPoster
    Join Date
    Feb 2017
    Posts
    3,232

    Re: how to intercept a string of a specified length by vb6?

    May be this:

    Code:
    Length = Len("""" & Replace$(Replace$(Replace$(Replace$(Replace$(Replace$(InputText, """", """"""), vbTab, """ & vbTab & """), vbCrLf, """ & vbCrLf & """), vbCr, """ & vbCr & """), vbLf, """ & vbLf & """), "& """" ", "") & """")

  8. #8

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: how to intercept a string of a specified length by vb6?

    I want to turn a relatively long string into a multi-line VB code, and each line just puts the maximum number of characters.
    There are many ways to save strings, such as StringBuilder.txt, a data1.txt is stored in the resource, or data1.txt can be placed directly in the software directory, and the released software is compressed into a zip together.
    This is just to discuss the method of just concatenating with strings or saving in arrays.

    Code:
    Private Sub Form_Load()
    'text1.text=
    
    'a = a & "*"
    'abc = abc & "*"
    'sz(n) = "*"
    'sz(nn) = "*"
    
    End Sub
    Private Sub Command1_Click()
    Dim S As String, Arr1, I As Long
    Dim Stest As String
    Dim LineMaxLen As Long, CutStrLen As Long, LenA As Long
    LineMaxLen = 1024
    
    Stest = "abc●〓" & Chr(9) & vbCrLf & vbLf & Chr(9) & vbCr & vbCrLf
    For I = 1 To LineMaxLen '1000
        S = S & I & Stest
    Next
    
    MsgBox S
    Arr1 = Split(Text1.Text, vbCrLf)
      
    Debug.Print "LineMaxLen=" & LineMaxLen
    For I = 0 To UBound(Arr1)
        LenA = Len(Arr1(I)) - 1
        CutStrLen = LineMaxLen - LenA
        Debug.Print Arr1(I) & ",LenA=" & LenA & ",CutStrLen=" & CutStrLen
    Next
    End Sub
    Code:
    LineMaxLen=1024
    a = a & "*",LenA=10,CutStrLen=1014
    abc = abc & "*",LenA=14,CutStrLen=1010
    sz(n) = "*",LenA=10,CutStrLen=1014
    sz(nn) = "*",LenA=11,CutStrLen=1013
    len('a')=1
    len('●')=2?
    Does 1024 refer to the length of a single byte, or are all Chinese characters also 1024? Is the length of UNICODE characters counted as one or two?
    Last edited by xiaoyao; May 13th, 2021 at 09:46 PM.

  9. #9

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: how to intercept a string of a specified length by vb6?

    https://github.com/douglascrockford/...aster/json2.js
    17KB
    VB6 STR CODE FOR THIS FILE LIKE:
    S = S & "**"

    OR
    S="AAAAA*" _
    & "*****" _
    & "******"

    OR
    DIM arr()
    redim arr(x)
    arr(0) = "**"
    ***
    arr(10) = "**"

    want a function Like StrToVBcode:
    Code:
    Function StrToVBcode(str As String, ByArr As Boolean, varName As String, Optional Use_ As Boolean) As String()
     '*** vb code
    End Function
    Sub TEST()
    Dim S As String
    S = Clipboard.GetText 'OR OPEN TXT FILE
    Dim vbcode As String
    vbcode = StrToVBcode(S, False, "JsCode")
    
    'Dim JsCode As String
    'JsCode = "a*****"
    'JsCode = JsCode & "b****"
    
    vbcode = StrToVBcode(S, False, "JsCode", True)
    'Dim JsCode As String
    'JsCode = "a*****" _
    '& "b****" _
    '& "c****" _
    '& "d***"
    
    vbcode = StrToVBcode(S, True, "JsCodeArr")
    Dim JsCodeArr() As String
    ReDim JsCodeArr(100)
    JsCodeArr(0) = "****"
    JsCodeArr(1) = "***"
    '*
    JsCodeArr(100) = "***"
    End Sub
    Last edited by xiaoyao; May 13th, 2021 at 10:03 PM.

  10. #10

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: how to intercept a string of a specified length by vb6?

    This is the way with the least code
    【String line breaks "_" are spliced, and cannot exceed 25 lines, otherwise an error occurs, and the prompt "Too many line continuation flags"】
    Code:
    Function LineStrToVbCode_(ByVal Str As String, VarName As String, Optional ByConst As Boolean) As String
        Str = Replace(Str, Chr(34), Chr(34) & Chr(34))
        While Right(Str, 2) = vbCrLf
            Str = Left(Str, Len(Str) - 2)
        Wend
        LineStrToVbCode_ = IIf(ByConst, "Private Const " & VarName & " As String = ", "  Dim " & VarName & " As String : " & VarName & " = ") _
        & Chr(34) & Chr(34) & " _" & vbCrLf & "  & " & Chr(34) _
        & Replace(Str, vbCrLf, Chr(34) & " & vbCrLf _" & vbCrLf & "  & " & Chr(34)) _
        & Chr(34)
    End Function
    
      
    Private Const cConstName5 As String = "" _
      & "Dim a" & vbCrLf _
      & "Dim b" & vbCrLf _
      & "Dim c" & vbCrLf _
      & "a = ""2234333""" & vbCrLf _
      & "'afasfa" & vbCrLf _
      & "b = ""aafasdfa"" & Chr(34) '""" & vbCrLf _
      & "b = ""aafasdfa"" & Chr(34) '"""""
    
      Dim cConstName6 As String: cConstName6 = "" _
      & "Dim a" & vbCrLf _
      & "Dim b" & vbCrLf _
      & "Dim c" & vbCrLf _
      & "a = ""2234333""" & vbCrLf _
      & "'afasfa" & vbCrLf _
      & "b = ""aafasdfa"" & Chr(34) '""" & vbCrLf _
      & "b = ""aafasdfa"" & Chr(34) '"""""
    Last edited by xiaoyao; May 14th, 2021 at 03:17 AM.

  11. #11
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    2,798

    Re: how to intercept a string of a specified length by vb6?

    my guess..

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    
       Dim s As String
       Dim i As Long
       
       s = "1234567890"
       For i = 1 To 2
          s = s & s
       Next
       
       Text1.Text = s
    End Sub
    
    Private Sub Command1_Click()
    
       Dim i As Long
       Dim TLen As Long
          
          TLen = 4 '<- set number of characters
          For i = 0 To GetPartStringMaxIndex(Text1.Text, TLen)
             Print GetPartString(Text1.Text, i, TLen) & "X"
          Next
    
    End Sub
    
    
    Public Function GetPartString(sString As String, Index As Long, TLen As Long)
    
       Dim StartPos As Long
       
          StartPos = (Index * TLen) + 1
          GetPartString = Mid$(sString, StartPos, TLen)
    End Function
    
    Public Function GetPartStringMaxIndex(sString As String, TLen As Long)
    
       Dim i As Long
           
          i = (Len(sString) \ TLen) - 1
          If (Len(sString) Mod TLen) > 0 Then
             i = i + 1
          End If
          GetPartStringMaxIndex = i
    End Function
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  12. #12

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: how to intercept a string of a specified length by vb6?

    Quote Originally Posted by ChrisE View Post
    my guess..

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    
       Dim s As String
       Dim i As Long
       
       s = "1234567890"
       For i = 1 To 2
          s = s & s
       Next
       
       Text1.Text = s
    End Sub
    
    Private Sub Command1_Click()
    
       Dim i As Long
       Dim TLen As Long
          
          TLen = 4 '<- set number of characters
          For i = 0 To GetPartStringMaxIndex(Text1.Text, TLen)
             Print GetPartString(Text1.Text, i, TLen) & "X"
          Next
    
    End Sub
    
    
    Public Function GetPartString(sString As String, Index As Long, TLen As Long)
    
       Dim StartPos As Long
       
          StartPos = (Index * TLen) + 1
          GetPartString = Mid$(sString, StartPos, TLen)
    End Function
    
    Public Function GetPartStringMaxIndex(sString As String, TLen As Long)
    
       Dim i As Long
           
          i = (Len(sString) \ TLen) - 1
          If (Len(sString) Mod TLen) > 0 Then
             i = i + 1
          End If
          GetPartStringMaxIndex = i
    End Function
    Also need to deal with the length of the variable name, splicing character, double quotation mark in front. When encountering carriage return, TAB should also be converted into VB6 code, the length will increase a lot

  13. #13

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: how to intercept a string of a specified length by vb6?

    Want to realize 3 kinds of modes, convert the string into VB code, the number of characters in each line requires the most.
    There may be a small amount of spaces before each line, as well as variable names and splicing characters.

    Code:
    Sub test3()
        Dim StrA As String: StrA = "" _
        & "aaaaaaa" _
        & "bbbbbbb" _
        & "ccccccc"
    End Sub
    Sub test4()
        Dim StrA As String
        StrA = "aaaaaaa"
        StrA = StrA & "bbbbbbb"
        StrA = StrA & "ccccccc"
    End Sub
    Sub test5()
        Dim Sarr(2) As String
        Sarr(0) = "aaaaaaa"
        Sarr(1) = "bbbbbbb"
        Sarr(2) = "cccccc"
    End Sub

  14. #14

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: character string changes to VB code,maximized characters

    @admin @master
    Please transfer this topic to the code bank

  15. #15

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: how to intercept a string of a specified length by vb6?

    Quote Originally Posted by Eduardo- View Post
    May be this:

    Code:
    Length = Len("""" & Replace$(Replace$(Replace$(Replace$(Replace$(Replace$(InputText, """", """"""), vbTab, """ & vbTab & """), vbCrLf, """ & vbCrLf & """), vbCr, """ & vbCr & """), vbLf, """ & vbLf & """), "& """" ", "") & """")
    Yes, you need to convert these characters before calculating the length

  16. #16

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: how to intercept a string of a specified length by vb6?

    Text alignment is just a basic algorithm.
    Some custom controls are all self-drawn, just like table controls. It is very difficult to accurately calculate the border, the height and width of each column and each row, the click position, and the scroll position.

  17. #17
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    2,798

    Re: how to intercept a string of a specified length by vb6?

    Quote Originally Posted by xiaoyao View Post
    Also need to deal with the length of the variable name, splicing character, double quotation mark in front. When encountering carriage return, TAB should also be converted into VB6 code, the length will increase a lot
    I can't follow what you want
    do you want to remove Characters? or ????

    did you try regex to split at the n Character
    Code:
    Private Sub Command1_Click()
    Dim TXT As String
    Dim regSplit As Match
    
       TXT = "Want to realize 3 kinds of modes, convert the " & vbCrLf & _
      " string into VB code, ''the'' number of ""characters"" in each line requires the most."
      With New RegExp
            .Pattern = "(.{0,24})(?: |$)"  '< split every n Characters
            .Global = True
              For Each regSplit In .Execute(TXT)
                    Debug.Print regSplit.Value
              Next
      End With
    End Sub
    debug output
    Code:
    Want to realize 3 kinds 
    of modes, convert the 
     string into VB code, 
    ''the'' number of 
    "characters" in each 
    line requires the most.
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  18. #18

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Convert string to VB6 code,maximized characters

    vbcrlf,chr(9),chr(34),vbcr,vblf,These special symbols can not be displayed directly in the vb6 code. Therefore, when obtaining the length, it needs to be converted into code, which makes it difficult to intercept the fixed length.
    You can test a relatively large notepad file, it into VB code.Maximum number of words per line

  19. #19
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    4,532

    Re: Convert string to VB6 code,maximized characters

    What is the use case?
    Or is this another hypothetical question?

    Why not store the large string in file or a resource file?

  20. #20
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,543

    Re: Convert string to VB6 code,maximized characters

    Looking at the example on post #10 it makes less sense than before.
    Why on earth would you be combining multiple lines using line breaks and continuation characters.
    That just makes the code longer and harder to read.

    I also do not under why you would want to try and achieve max line length. Not exceeding max length makes sense but you should never try to add as much as allowed on a single line. I can't even imagine trying to read a code module where every line has 1000+ characters stuffed in there. That would be extremely hard to read and/or debug.

  21. #21
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    2,798

    Re: Convert string to VB6 code,maximized characters

    Quote Originally Posted by xiaoyao View Post
    vbcrlf,chr(9),chr(34),vbcr,vblf,These special symbols can not be displayed directly in the vb6 code. Therefore, when obtaining the length, it needs to be converted into code, which makes it difficult to intercept the fixed length.
    You can test a relatively large notepad file, it into VB code.Maximum number of words per line
    that is just nonsense,for what purpose?
    I'm outa here
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  22. #22

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Convert string to VB6 code,maximized characters

    It was clearly stated in the question I sent at the beginning.I'm actually putting a piece of json2.js into the code.

    After the old version was compressed, basically two or three lines were enough.If not compressed, up to 22 lines.

    Here is mainly to discuss one. A shorter string, perhaps three or five lines long.Of course,.

    For most purposes, just show it as a line.Or just convert it to hexadecimal.For example, someone used to assemble the program msam.exe, put it as a string, loaded inside the software.
    Last edited by xiaoyao; May 14th, 2021 at 09:34 AM.

  23. #23

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Convert string to VB6 code,maximized characters

    On the processing of strings here to learn.For example, disassemble each function for him, how many variables and what type are there?

    This involves syntax analysis, string extraction and so on.This is also a consideration if you need to add a long block of comment text.

  24. #24

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Convert string to VB6 code,maximized characters

    Quote Originally Posted by DataMiser View Post
    Looking at the example on post #10 it makes less sense than before.
    Why on earth would you be combining multiple lines using line breaks and continuation characters.
    That just makes the code longer and harder to read.

    I also do not under why you would want to try and achieve max line length. Not exceeding max length makes sense but you should never try to add as much as allowed on a single line. I can't even imagine trying to read a code module where every line has 1000+ characters stuffed in there. That would be extremely hard to read and/or debug.
    You can put very long strings of these in a module.
    In fact, these technologies are only part of my code generation tool.

    For example, a function, how many APIs does it have, if you add more than one function, a lot of process code may be repeated.Code editor to deal with a lot of characters, just this instruction length, line feed is only the most basic functions.Including code formatting and so on.

  25. #25
    Frenzied Member
    Join Date
    Nov 2017
    Posts
    1,565

    Re: Convert string to VB6 code,maximized characters

    Quote Originally Posted by xiaoyao View Post
    It was clearly stated in the question I sent at the beginning.
    LOL.

    The good news is that being able to use humor in a language is a sign of understanding that language. Keep it up!

  26. #26
    PowerPoster
    Join Date
    Feb 2017
    Posts
    3,232

    Re: Convert string to VB6 code,maximized characters

    It makes sense to me. It is to store large text in the program without having to use resource files or any external file.

    Why take advantage of all the possible line length? To use less lines as possible, since that code is non intended to be human readable.
    I updated the script with the option.
    (still, not sure if that is what xiaoyao is asking)

  27. #27
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,543

    Re: Convert string to VB6 code,maximized characters

    Quote Originally Posted by Eduardo- View Post
    It makes sense to me. It is to store large text in the program without having to use resource files or any external file.

    Why take advantage of all the possible line length? To use less lines as possible, since that code is non intended to be human readable.
    I updated the script with the option.
    (still, not sure if that is what xiaoyao is asking)
    Except in the example posted it shows VBCode, multiple lines with line feeds all thrown together making it much longer than it needs to be. It really makes no sense at all to me.

  28. #28
    PowerPoster
    Join Date
    Feb 2017
    Posts
    3,232

    Re: Convert string to VB6 code,maximized characters

    Quote Originally Posted by DataMiser View Post
    Except in the example posted it shows VBCode, multiple lines with line feeds all thrown together making it much longer than it needs to be. It really makes no sense at all to me.
    What example?

  29. #29

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Convert string to VB6 code,maximized characters

    Many people say that VB6 is no longer worth using. VB.NET will also be eliminated by Microsoft.
    Everyone has so many opinions.
    In fact, I just want to pursue such an algorithm.

    In fact, I found that my code seems to be very long.I wonder if anyone can understand it and optimize it.

    It's like the string splitting code I wrote before, using the pointer method.

  30. #30

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Convert string to VB6 code,maximized characters

    In the past I've used multi-line text concatenation, mostly for web post submissions. For example, data collection, crawlers automatically release information. You may need to post five to ten different addresses from login to operation. The data of each post is different. Key, value, equivalent to JSON data. a=1&b=k&c=33 Some data are fixed, and some are constantly changing. I couldn't think of a better way, so I went with an array of strings.
    dim postArr()
    redim postArr(1)
    postArr(0)="a=" & "1"
    postArr(1)="b=" & bvalue

  31. #31

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Convert string to VB6 code,maximized characters

    Quote Originally Posted by Eduardo- View Post
    It makes sense to me. It is to store large text in the program without having to use resource files or any external file.

    Why take advantage of all the possible line length? To use less lines as possible, since that code is non intended to be human readable.
    I updated the script with the option.
    (still, not sure if that is what xiaoyao is asking)
    Yes, we just want to give him a string to save in code.You do not need to use a resource file.

    For example, he used a lot of JS encryption code in the process of web post.After using it, you can not use the resource file.Using resource files is the best approach, though.

  32. #32
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,183

    Re: Convert string to VB6 code,maximized characters

    Blah!

  33. #33

    Thread Starter
    Taking a Break
    Join Date
    Jan 2020
    Posts
    1,340

    Re: Convert string to VB6 code,maximized characters

    Quote Originally Posted by Magic Ink View Post
    Blah!
    Please pay attention to the civilized English of the forum.

    Some people ask questions in special ways.
    Its method may not be the best, but it may be simpler.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width