{"id":1921,"date":"2014-11-13T21:29:58","date_gmt":"2014-11-13T21:29:58","guid":{"rendered":"https:\/\/alt2.minisoft.com\/support\/?p=1921"},"modified":"2020-06-11T13:56:09","modified_gmt":"2020-06-11T20:56:09","slug":"using-data-access-from-vb-with-arrays","status":"publish","type":"post","link":"https:\/\/www.minisoft.com\/support\/using-data-access-from-vb-with-arrays\/","title":{"rendered":"Using Data Access &#8211; From VB with Arrays"},"content":{"rendered":"<p>The MDMDA session object is being called from a Visual Basic 5.0 application. This sample includes references to an item array (12J1).<\/p>\n<p class=\"subheads\">The dataset and items are defined as follows:<\/p>\n<pre>ITEMS:\nITEM-NO, Z6;\nSALES-PERIODS, 12X6;\nSALES-HISTORY, 12P12;\nMISC, 12J1;\nOTHER, J2;\n\nSETS:\nNAME: HISTORY, DETAIL (1\/18);\nENTRY: ITEM-NO(!HISTORY-M),\nSALES-PERIODS,\nSALES-HISTORY,\nMISC,\nOTHER;\nCAPACITY: 101;\nEND.<\/pre>\n<p><a href=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2014\/11\/mdm_002.gif\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1922\" src=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2014\/11\/mdm_002.gif\" alt=\"mdm_002\" width=\"380\" height=\"265\"><\/a><\/p>\n<pre>Option Explicit\nDim ds As Object\nDim db As Object\nDim da As Object\nDim t1 As String\nConst j1 = 6<\/pre>\n<hr size=\"1\">\n<pre>Private Sub GetItemValues()\n\nDim ii As Integer\n\nt1 = \"\"\nds.Item(\"ITEM-NO\") = Text1.Text\nFor ii = 0 To 11\nt1 = t1 + Right(\" \" + MISC(ii).Text,j1)\nNext ii\nText2.Text = t1\nds.Item(\"MISC\") = t1\n\nEnd Sub<\/pre>\n<hr size=\"1\">\n<pre>Private Sub SetItemValues()\n\nDim ii As Integer\n\nText1.Text = ds.Item(\"ITEM-NO\")\nt1 = ds.Item(\"MISC\")\nText2.Text = t1\nFor ii = 0 To 11\nMISC(ii).Text = Val(Mid(t1, (1 + (ii * j1)),j1))\nNext ii\n\nEnd Sub<\/pre>\n<hr size=\"1\">\n<pre>Private Sub Add_Click()\n\nGetItemValues\n\nIf Not ds.DBPut(1, \"@;\") Then\nMsgBox (\"DBPut failed: \" + ds.errormessage)\nExit Sub\nEnd If\n\nEnd Sub<\/pre>\n<hr size=\"1\">\n<pre>Private Sub Find_Click()\n\nIf Not ds.DBFind(1, \"PTYPE\", tFind.Text) Then\nMsgBox (\"DBFind failed: \" + ds.errormessage)\nExit Sub\nElse\nIf Not ds.DBGet(5, \"@;\", \"X\") Then\nMsgBox (\"DBGet failed: \" + ds.errormessage)\nExit Sub\nEnd If\nEnd If\n\nSetItemValues\n\nEnd Sub<\/pre>\n<hr size=\"1\">\n<pre>Private Sub Form_Load()\n\nSet da = CreateObject(\"MdmDA.Session\")\nda.TraceLevel = 0\nda.HostAddress = \"support\"\nda.Port = \"30002\"\nda.LoginUser = \"mgr\"\nda.UserPassword = InputBox(\"user password\")\nda.LoginGroup = \"util\"\nda.LoginAccount = \"minisoft\"\nIf Not da.Connect Then\nMsgBox \"Connect failed\"\nExit Sub\nEnd If\nIf da.LoginStatus = False Then\nMsgBox \"Login failed\"\nExit Sub\nEnd If\nSet db = da.AddImageDBRef(\"MSCARD\")\nSet ds = db.AddDatasetRef(\"HISTORY\")\nIf Not db.DBOpen(\"MSCARD.UTIL.MINISOFT\", \"DO-ALL\", 1) Then\nMsgBox \"Open failed\"\nExit Sub\nEnd If\nds.Delimiter = \"\"\nNext_Click\n\nEnd Sub<\/pre>\n<hr size=\"1\">\n<pre>Private Sub Next_Click()\n\nIf Not ds.DBGet(2, \"@;\", \"X\") Then\nMsgBox (\"DBGet failed: \" + ds.errormessage)\nExit Sub\nEnd If\n\nSetItemValues\n\nEnd Sub<\/pre>\n<hr size=\"1\">\n<pre>Private Sub Rewind_Click()\n\nds.rewind\n\nEnd Sub<\/pre>\n<hr size=\"1\">\n<p><strong>Sample<\/strong><br \/>\n[<a href=\"\/support\/wp-content\/uploads\/2014\/11\/sample5.zip\">sample5.zip<\/a>]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The MDMDA session object is being called from a Visual Basic 5.0 application. This sample includes references to an item array (12J1). The dataset and items are defined as follows: ITEMS: ITEM-NO, Z6; SALES-PERIODS, 12X6; SALES-HISTORY, 12P12; MISC, 12J1; OTHER, J2; SETS: NAME: HISTORY, DETAIL (1\/18); ENTRY: ITEM-NO(!HISTORY-M), SALES-PERIODS, SALES-HISTORY, MISC, OTHER; CAPACITY: 101; END. [&hellip;]<\/p>\n","protected":false},"author":75,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61,54],"tags":[],"_links":{"self":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/1921"}],"collection":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/comments?post=1921"}],"version-history":[{"count":3,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/1921\/revisions"}],"predecessor-version":[{"id":8030,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/1921\/revisions\/8030"}],"wp:attachment":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/media?parent=1921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/categories?post=1921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/tags?post=1921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}