hexagon logo

Learning coding

Where did you all learn coding?

I have one very basic code that was mainly copied from on here but I want to do more. So where did everyone learn this? Coworkers, books, Google, YouTube, classes, guy in a van down by the river??? What reading materials/websites/videos/classes/guys in vans by rivers would you recommend? I am going to take the free (until June) "VB.Net for PC-DMIS 301" class online probably this weekend. I see what you guys are having DMIS do with coding and I see how it can greatly help here at my job so I want to learn as much as I can. I'm the kind of person that is thirsty for knowledge and can't learn enough. My boss has had conversations with the owner and myself about sending me to classes at the local community college and they are all for it but that's on hold until this virus blows over.

Any recommendations you guys have are greatly appreciated.
Parents
  • One major improvement with automating PCDMIS I learned along the way was using a "BackgroundWorker" (there are other ways to accomplish this as well) to execute certain tasks. One thing you'll eventually notice is that when you hit a button and the buttons "freeze" until the code block(s) finish executing, running a part program for example.

    Below is an example of launching pcdmis with a BackgroundWorker. I just copied and pasted this so if you have a question about what something is let me know

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using PCDLRN;
    using Microsoft.VisualBasic;
    using System.Diagnostics;
    using System.IO.Compression;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.ComponentModel;
    using System.Windows.Interop;
    
    namespace PCD_Operator_App
    {
        /// <summary>
        /// Interaction logic for LoadScreen.xaml
        /// </summary>
        public partial class LoadScreen : Window
        {
            private const int GWL_STYLE = -16;
            private const int WS_SYSMENU = 0x80000;
    
            [DllImport("user32.dll", SetLastError = true)]
            private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
    
            [DllImport("user32.dll")]
            private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    
            public LoadScreen()
            {
                InitializeComponent();
    
                BackgroundWorker backgroundStartup = new BackgroundWorker();
                backgroundStartup.WorkerReportsProgress = true;
                backgroundStartup.DoWork += startup_DoWork;
                backgroundStartup.ProgressChanged += startup_ProgressChanged;
                backgroundStartup.RunWorkerCompleted += startup_RunWorkerCompleted;
                backgroundStartup.RunWorkerAsync();
            }
            void startup_DoWork(object sender, DoWorkEventArgs e)
            {
                bool startCondition = true;
    
                Process[] pcdStartupCheck = Process.GetProcessesByName("PCDLRN");
                if (pcdStartupCheck.Length > 0)
                {
                    startCondition = false;
                }
                else
                {
                    Type PCDRLN_Application = null;
                    object PCDObj = null;
    
                    PCDLRN.Application PCDApp = null;
    
                    try
                    {
                        PCDRLN_Application = Type.GetTypeFromProgID("PCDLRN.Application");
    
                        PCDObj = Activator.CreateInstance(PCDRLN_Application);
                    }
                    catch (System.Exception em)
                    {
                        MessageBox.Show(em.Message);
                    }
    
                    PCDApp = new PCDLRN.Application();
    
                    PCDApp.OperatorMode = true;
    
                    PCDApp.Visible = false;
    
                    PCDApp.ApplicationEvents.OnMachineConnected += new IApplicationEvents_OnMachineConnectedEventHandler(onMachineConnect);
    
                    void onMachineConnect(Machine machine)
                    {
                        //MessageBox.Show("machine connected");
                        //loadScreenStatus.Content = "PC-DMIS active, connecting to machine...";
    
                        startCondition = false;
                    }
    
                    if (startCondition)
                    {
                        WindowSearcher homeWindowSearch = new WindowSearcher();
                        homeWindowSearch.BeginWindowLook_Home();
                    }
                }
            }
    
            void startup_ProgressChanged(object sender, ProgressChangedEventArgs e)
            {
                
            }
    
            void startup_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
            {
                new MainWindow().Show();
    
                this.Close();
            }
    
            private void WindowLoaded(object sender, RoutedEventArgs e)
            {
                var hwnd = new WindowInteropHelper(this).Handle;
                SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
            }
        }
    }
    
    
Reply
  • One major improvement with automating PCDMIS I learned along the way was using a "BackgroundWorker" (there are other ways to accomplish this as well) to execute certain tasks. One thing you'll eventually notice is that when you hit a button and the buttons "freeze" until the code block(s) finish executing, running a part program for example.

    Below is an example of launching pcdmis with a BackgroundWorker. I just copied and pasted this so if you have a question about what something is let me know

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using PCDLRN;
    using Microsoft.VisualBasic;
    using System.Diagnostics;
    using System.IO.Compression;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.ComponentModel;
    using System.Windows.Interop;
    
    namespace PCD_Operator_App
    {
        /// <summary>
        /// Interaction logic for LoadScreen.xaml
        /// </summary>
        public partial class LoadScreen : Window
        {
            private const int GWL_STYLE = -16;
            private const int WS_SYSMENU = 0x80000;
    
            [DllImport("user32.dll", SetLastError = true)]
            private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
    
            [DllImport("user32.dll")]
            private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    
            public LoadScreen()
            {
                InitializeComponent();
    
                BackgroundWorker backgroundStartup = new BackgroundWorker();
                backgroundStartup.WorkerReportsProgress = true;
                backgroundStartup.DoWork += startup_DoWork;
                backgroundStartup.ProgressChanged += startup_ProgressChanged;
                backgroundStartup.RunWorkerCompleted += startup_RunWorkerCompleted;
                backgroundStartup.RunWorkerAsync();
            }
            void startup_DoWork(object sender, DoWorkEventArgs e)
            {
                bool startCondition = true;
    
                Process[] pcdStartupCheck = Process.GetProcessesByName("PCDLRN");
                if (pcdStartupCheck.Length > 0)
                {
                    startCondition = false;
                }
                else
                {
                    Type PCDRLN_Application = null;
                    object PCDObj = null;
    
                    PCDLRN.Application PCDApp = null;
    
                    try
                    {
                        PCDRLN_Application = Type.GetTypeFromProgID("PCDLRN.Application");
    
                        PCDObj = Activator.CreateInstance(PCDRLN_Application);
                    }
                    catch (System.Exception em)
                    {
                        MessageBox.Show(em.Message);
                    }
    
                    PCDApp = new PCDLRN.Application();
    
                    PCDApp.OperatorMode = true;
    
                    PCDApp.Visible = false;
    
                    PCDApp.ApplicationEvents.OnMachineConnected += new IApplicationEvents_OnMachineConnectedEventHandler(onMachineConnect);
    
                    void onMachineConnect(Machine machine)
                    {
                        //MessageBox.Show("machine connected");
                        //loadScreenStatus.Content = "PC-DMIS active, connecting to machine...";
    
                        startCondition = false;
                    }
    
                    if (startCondition)
                    {
                        WindowSearcher homeWindowSearch = new WindowSearcher();
                        homeWindowSearch.BeginWindowLook_Home();
                    }
                }
            }
    
            void startup_ProgressChanged(object sender, ProgressChangedEventArgs e)
            {
                
            }
    
            void startup_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
            {
                new MainWindow().Show();
    
                this.Close();
            }
    
            private void WindowLoaded(object sender, RoutedEventArgs e)
            {
                var hwnd = new WindowInteropHelper(this).Handle;
                SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
            }
        }
    }
    
    
Children