{"id":2526,"date":"2015-02-12T21:52:39","date_gmt":"2015-02-12T19:52:39","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=2526"},"modified":"2015-02-12T22:12:43","modified_gmt":"2015-02-12T20:12:43","slug":"visual-basic-6-mini-guide-for-developpers","status":"publish","type":"post","link":"https:\/\/www.extradrm.com\/?p=2526","title":{"rendered":"Visual Basic 6 : some useful functions"},"content":{"rendered":"<p>VB 6 introduced<strong> a trio of powerful functions that operate on string arrays<\/strong>. These functions save the coding effort of having to set up loops and using combinations of other basic string functions to perform the equivalent tasks.<\/p>\n<p><b>Split(<\/b><i>expression<\/i>[<b>,<\/b> <i>delimiter<\/i>[<b>,<\/b> <i>count<\/i>[<b>,<\/b> <i>compare<\/i>]]]<b>)<br \/>\nJoin(<\/b><i>list<\/i>[, <i>delimiter<\/i>]<b>)<\/b><br \/>\n<b>Filter(<\/b><i>InputStrings<\/i><b>,<\/b> <i>Value<\/i>[<b>,<\/b> <i>Include<\/i>[<b>,<\/b> <i>Compare<\/i>]]<b>)<\/b><\/p>\n<p>Here are two <strong>visual basic 6<\/strong> programs for reading and writing files with visual basic sequential file :<\/p>\n<p>Sub Extraction_PhotosMiningSplit()<br \/>\nOn Error GoTo Err_Extraction_PhotosMiningSplit_Click<\/p>\n<p>Dim i As Integer<br \/>\nDim ISN As String<br \/>\nDim ligne As String<\/p>\n<p>filein = &#8220;C:\\phototeque\\photodoc.txt&#8221;<\/p>\n<p>ISN = &#8220;&#8221;<br \/>\nClose #1<br \/>\nClose #2<\/p>\n<p>Dim partie1 As Integer<\/p>\n<p>partie1 = 0<\/p>\n<p>Open filein For Input As 1<br \/>\nOpen &#8220;c:\\phototeque\\split_class2.txt&#8221; For Output As #2<\/p>\n<p>MsgBox &#8220;Reading\u00a0 Photos file line by line &#8230; &#8221;<\/p>\n<p>Do While Not EOF(1)<br \/>\nLine Input #1, ligne<\/p>\n<p>If InStr(1, ligne, &#8220;$DOC_ISN&#8221;) &lt;&gt; 0 Then<br \/>\nLine Input #1, ligne<br \/>\n&#8216;Print #2, ligne;<br \/>\n&#8216;Print #2, Chr$(9);<br \/>\nISN = ligne<br \/>\nGoTo Suite<br \/>\nEnd If<\/p>\n<p>&#8216;$DOC_CLASS2<br \/>\n&#8216;CIMETIERE<strong>$SEP$<\/strong>POTERIE<strong>$SEP$<\/strong>VILLE<\/p>\n<p>If InStr(1, ligne, &#8220;$DOC_CLASS2&#8221;) &lt;&gt; 0 Then<br \/>\nLine Input #1, ligne<br \/>\n&#8216;Print #2, ligne;<br \/>\n&#8216;Print #2, Chr$(9)<\/p>\n<p>astrSplitItems = Split(ligne, &#8220;$SEP$&#8221;)<\/p>\n<p>For intX = 0 To UBound(astrSplitItems)<\/p>\n<p>Print #2, ISN;<br \/>\nPrint #2, Chr$(9); &#8216;tab char code<br \/>\nPrint #2, astrSplitItems(intX)<\/p>\n<p>Next<\/p>\n<p>partie1 = 1<br \/>\nGoTo Suite<br \/>\nEnd If<\/p>\n<p>If InStr(1, ligne, &#8220;\/\/FINENREG&#8221;) &lt;&gt; 0 Then<\/p>\n<p>If partie1 = 0 Then<br \/>\nPrint #2, Chr$(9)<br \/>\nElse<br \/>\npartie1 = 0<br \/>\nEnd If<\/p>\n<p>GoTo Suite<\/p>\n<p>End If<\/p>\n<p>Suite:<br \/>\nLoop<\/p>\n<p>Close #1<br \/>\nClose #2<br \/>\n&#8216;Kill fileout<\/p>\n<p>&#8216;Name &#8220;c:\\tempbr.tmp&#8221; As fileout<\/p>\n<p>MsgBox &#8220;End Mining des Photos &#8230; &#8221;<\/p>\n<p>Exit_Extraction_PhotosMiningSplit_Click:<br \/>\nExit Sub<\/p>\n<p>Err_Extraction_PhotosMiningSplit_Click:<br \/>\nMsgBox Err.Description<br \/>\nResume Exit_Extraction_PhotosMiningSplit_Click<\/p>\n<p>End Sub<\/p>\n<p>======== SolR Data generated by VB6 sample ==========<\/p>\n<p>Sub Extraction_PhotoSolr()<br \/>\nOn Error GoTo Err_Extraction_PhotoSolr_Click<\/p>\n<p>Dim ligne As String<br \/>\nfilein = &#8220;C:\\phototeque\\photos_doc.txt&#8221;<\/p>\n<p>Close #1<br \/>\nClose #2<br \/>\nDim id_isn As Double<br \/>\nDim partie As Integer<\/p>\n<p>Open filein For Input As 1<br \/>\nOpen &#8220;c:\\phototeque\\indexdata_solr.txt&#8221; For Output As #2<\/p>\n<p>&#8216;objFile.WriteLine &#8220;&lt;? xml version = &#8221; &amp; Chr(34) &amp; &#8220;1.0&#8221; &amp; Chr(34) &amp; _<br \/>\n&#8216;\u00a0\u00a0 &#8221; encoding = &#8221; &amp; Chr(34) &amp; &#8220;UTF-8&#8243; &amp; Chr(34) &amp; &#8221; ?&gt;&#8221;<\/p>\n<p>&#8216; Chr(34) code char des double quote<\/p>\n<p>MsgBox &#8220;Extraction des Photos &#8230; &#8221;<\/p>\n<p>Do While Not EOF(1)<br \/>\nLine Input #1, ligne<\/p>\n<p>If InStr(1, ligne, &#8220;$DOC_DP&#8221;) &lt;&gt; 0 Then<\/p>\n<p>Line Input #1, ligne<br \/>\nPrint #2, &#8220;&lt;field name=&#8221; &amp; Chr(34) &amp; &#8220;typeres&#8221; &amp; Chr(34) &amp; &#8220;&gt;&#8221;;<br \/>\nPrint #2, ligne;<br \/>\nPrint #2, &#8220;&lt;\/field&gt;&#8221;<br \/>\nGoTo Suite<br \/>\nEnd If<\/p>\n<p>If InStr(1, ligne, &#8220;$DOC_ISN&#8221;) &lt;&gt; 0 Then<\/p>\n<p>Line Input #1, ligne<br \/>\nPrint #2, &#8220;&lt;field name=&#8221; &amp; Chr(34) &amp; &#8220;id&#8221; &amp; Chr(34) &amp; &#8220;&gt;&#8221;;<br \/>\nPrint #2, ligne;<br \/>\nPrint #2, &#8220;&lt;\/field&gt;&#8221;<br \/>\nGoTo Suite<br \/>\nEnd If<\/p>\n<p>If InStr(1, ligne, &#8220;$DOC_TITRE&#8221;) &lt;&gt; 0 Then<\/p>\n<p>Line Input #1, ligne<br \/>\nPrint #2, &#8220;&lt;field name=&#8221; &amp; Chr(34) &amp; &#8220;titre&#8221; &amp; Chr(34) &amp; &#8220;&gt;&#8221;;<br \/>\nPrint #2, ligne;<br \/>\nPrint #2, &#8220;&lt;\/field&gt;&#8221;<br \/>\nGoTo Suite<br \/>\nEnd If<\/p>\n<p>If InStr(1, ligne, &#8220;$DOC_NUMINVENT&#8221;) &lt;&gt; 0 Then<\/p>\n<p>Line Input #1, ligne<br \/>\nPrint #2, &#8220;&lt;field name=&#8221; &amp; Chr(34) &amp; &#8220;idimg&#8221; &amp; Chr(34) &amp; &#8220;&gt;&#8221;;<br \/>\nPrint #2, ligne;<br \/>\nPrint #2, &#8220;&lt;\/field&gt;&#8221;<br \/>\nGoTo Suite<br \/>\nEnd If<\/p>\n<p>If InStr(1, ligne, &#8220;\/\/FINENREG&#8221;) &lt;&gt; 0 Then<\/p>\n<p>&#8216; end of record tag<\/p>\n<p>Print #2, &#8220;&lt;\/add&gt;&#8221;<br \/>\nPrint #2, &#8220;&lt;\/doc&gt;&#8221;<\/p>\n<p>Print #2, &#8220;&lt;add&gt;&#8221;<br \/>\nPrint #2, &#8220;&lt;doc&gt;&#8221;<\/p>\n<p>GoTo Suite<\/p>\n<p>End If<\/p>\n<p>Suite:<br \/>\nLoop<\/p>\n<p>Close #1<br \/>\nClose #2<br \/>\n&#8216;Kill fileout<br \/>\n&#8216;Name &#8220;c:\\tempbr.tmp&#8221; As fileout<\/p>\n<p>MsgBox &#8220;Fin Extraction index SolR Photos &#8230; &#8221;<\/p>\n<p>Exit_Extraction_PhotoSolr_Click:<br \/>\nExit Sub<\/p>\n<p>Err_Extraction_PhotoSolr_Click:<br \/>\nMsgBox Err.Description<br \/>\nResume Exit_Extraction_PhotoSolr_Click<\/p>\n<p>End Sub<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>VB 6 introduced a trio of powerful functions that operate on string arrays. These functions save the coding effort of having to set up loops and using combinations of other basic string functions to&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2846,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[283,294],"tags":[333],"youtube_video":null,"_links":{"self":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/2526"}],"collection":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2526"}],"version-history":[{"count":0,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/2526\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2846"}],"wp:attachment":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}