Several times, I have had to implement multidimensional array constructs using JavaScript but encountered difficulties. Since then, I'd been using other languages to achieve this purpose. But recently, I was able to devise a way around it which I would like to share: //Snippet var k = 0; var rows = new Array(4); var cols = new Array(4); var multiArray = new Array(rows, cols); //initialization of values for(var i=0; i<4; i++){ for(var j=0; j<4; j++){ multiArray[i][j] = ++k; } } //prints out values into HTML body in a web browser for(var i=0; i<4; i++){ for(var j=0; j<4; j++){ document.writeln(' '+multiArray[i][j]); } } I believe the code snippet is easy to comprehend and use. A simple guide: The 'cells' are initialized with values using loop construct. And in the second loop block the values will be displayed into the body of a webpage. But it's interesting to know that JavaScript doesn't yet have an inherit way of programming multidimensional array. This implementation and any other that you might come across won't support many of the properties and methods like implementation in strong type languages (C++, C#, etc). Hopefully, there would be a library that will support all the features of multidimensional array implementation in JavaScript. I'd like to attend to your questions, if you've any.
HubSnippets
Posts
-
Multidimensional Array in JavaScript -
Multidimensional Array in JavaScriptSeveral times, I have had to implement multidimensional array constructs using JavaScript but encountered difficulties. Since then, I'd been using other languages to achieve this purpose. But recently, I was able to devise a way around it which I would like to share: //Snippet var k = 0; var rows = new Array(4); var cols = new Array(4); var multiArray = new Array(rows, cols); for(var i=0; i<4; i++){ for(var j=0; j<4; j++){ multiArray[i][j] = ++k; } } for(var i=0; i<4; i++){ for(var j=0; j<4; j++){ document.writeln('
'+multiArray[i][j]); } } I believe the code snippet is easy to comprehend and use. But it's interesting to know that JavaScript doesn't yet have an inherit way of programming multidimensional array. This implementation and any other that you might come across won't support many of the properties and methods like implementation in strong type languages (C++, C#, etc). Hopefully, there would be a library that will support all the features of multidimensional array implementation in JavaScript. -
SearchDirectoryIf well built, preferably using MVS 2008, you should be able to select a directory by clicking on the "Browse" search button. When you click the search button, the directory tree of your hard drive would be displayed as "Browse For Folder" dialog box. Browse for a particular folder and click on the "Search Button". Then you can search for your preferred file type or all the files (using *.* for file type) in that directory. It is very seamless. I want to be able to select and highlight a file based on the file name the user inputs in the "TextBoxSearch".
-
SearchDirectoryI really intend to write an article about how the search feature of Windows Explorer can be improved. However, this post is meant to address the problem with locating and highlighting a file within the "ResultTextBox" using the "Find" button in the form. I have made attempts with "select" method but still would not work.
-
SearchDirectoryThe Microsoft Windows search "textbox" on the top-right corner of the Window Explorer is not too efficient when searching for files. So, I thought I should write something that would provide an easily way of searching for files in your Windows directories. There is a small application written to do a quick and smart search of files in a directory. It's still under development and your comments and contributions would be appreciated.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;
using System.Data.SqlClient;namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}private void btnBrowse\_Click(object sender, EventArgs e) { // Specify a Directory name or path into the File Directory TextBox FolderBrowserDialog openDir = new FolderBrowserDialog(); //Choose a Directory path name and display on the File Direcotry TextBox if (openDir.ShowDialog() == DialogResult.OK) txtBxDir.Text = openDir.SelectedPath; else MessageBox.Show("Make sure you have selected a valid path name"); } public void searchDirectory() { //Check for valid File Type and File Directory if (cmbBx.Text == "") MessageBox.Show("Input a valid file type format"); else if (txtBxDir.Text == "") MessageBox.Show("Input a valid directory pathname"); try { //Search the specified Directory for files of a particular file type String\[\] arrayFileList = Directory.GetFiles(txtBxDir.Text, cmbBx.Text, SearchOption.AllDirectories); foreach (string file in arrayFileList) { string fileName = file.Substring(file.LastIndexOf("\\\\") + 1); txtBxResult.Text += fileName + "\\r\\n"; } } catch (IOException) { MessageBox.Show("Choose the correct file type"); } } private string getTextBoxNoFiles() { string noFiles = txtBxResult.Lines.Length.ToString(); return txtBxNoFiles.Text = noFiles; }
-
C# with My SQLPlease I need a good walk-through on how to link my C# form with MySQL database. I also want to be able to retrieve data from my database. Thanks.