saint1000's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
18 (0.03 per day)
Joined:
22-January 13
Profile Views:
1,653
Last Active:
User is offline Feb 17 2014 06:14 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   saint1000 has not set their status

Posts I've Made

  1. In Topic: random number generator that wont pull same number twice in a row

    Posted 17 Feb 2014

    View Postthecoat, on 16 February 2014 - 07:52 AM, said:

    When you instantiate an integer variable it initially has a value of zero.

    Dim number As Integer
    


    Dim number As Integer = 0
    


    Dim number As Integer
    number = 0
    


    All three of these pieces of code end up in the same result. So any time Label2.text does not equal 0 when you call the function it is being set to 0 because the random call inside the do loop is skipped.

    Change line 2 to this:

    Dim number As Integer = CInt(Label2.Text)
    


    thank you. very helpfull!
  2. In Topic: random number generator that wont pull same number twice in a row

    Posted 16 Feb 2014

    i realize getting the same number twice in a row is random. just for my use i can not have the same number twice in a row.

      Dim rndnumber As Random
            Dim number As Integer
            rndnumber = New Random
            Do Until number <> Label2.Text
                number = rndnumber.Next(1, 5)
               
            Loop
    
            Label2.Text = number.ToString
    

    here is my random number generator. the number generator works fine until i add the loop. with the loop added it will start returning zero as one of my random numbers which i dont understand. my random number need to be 1-4. with out the loop it never gives me a zero.
  3. In Topic: usb relay board will not respond in vb.net unless test software is use

    Posted 16 Mar 2013

    it is a denkovi 12v 8 relay board. the c# example on their web page is the one i posted above. i thought this code was what put the board in bit bang mode


    040
            ftStatus = myFtdiDevice.SetBitMode(255, 4)
    
    
    
  4. In Topic: usb relay board will not respond in vb.net unless test software is use

    Posted 15 Mar 2013

    thanks i tried copying the button1 code in to my project and it still doesnt work. i figured i was missing somthing in the conversion
  5. In Topic: usb relay board will not respond in vb.net unless test software is use

    Posted 15 Mar 2013

    heres the c# code. this works. if i open this then close it then my code works.
    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 FTD2XX_NET;
    
    
    namespace WindowsFormsApplication1
    {
        
        public partial class Form1 : Form
        {
            public FTDI myFtdiDevice = new FTDI();
            FTDI.FT_STATUS ftStatus;
            byte[] sentBytes = new byte[2];
            uint receivedBytes;
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                
            }
    
            private void button1_Click_1(object sender, EventArgs e)
            {
                
                ftStatus = myFtdiDevice.OpenByIndex(0);
                if (ftStatus != FTDI.FT_STATUS.FT_OK)
                {
                    // Wait for a key press
                    Console.WriteLine("Failed to open device (error " + ftStatus.ToString() + ")");
                    Console.ReadKey();
                    return;
                }
    
                ftStatus = myFtdiDevice.SetBaudRate(921600);
                 if (ftStatus != FTDI.FT_STATUS.FT_OK)
                {
                    // Wait for a key press
                    Console.WriteLine("Failed to set baudrate (error " + ftStatus.ToString() + ")");
                    Console.ReadKey();
                    return;
                }
    
                 ftStatus = myFtdiDevice.SetBitMode(255,4);
                 if (ftStatus != FTDI.FT_STATUS.FT_OK)
                {
                    // Wait for a key press
                    Console.WriteLine("Failed to set bit mode (error " + ftStatus.ToString() + ")");
                    Console.ReadKey();
                    return;
                }
    
                 sentBytes[0] = 0;
            }
    
            private void checkBox1_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox1.Checked)
                   sentBytes[0]=(byte)(sentBytes[0] | 1);           
                else            
                    sentBytes[0]=(byte)(sentBytes[0] & 254);             
                myFtdiDevice.Write(sentBytes, 1, ref receivedBytes);
            }
    
            private void checkBox2_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox2.Checked)
                    sentBytes[0] = (byte)(sentBytes[0] | 2);
                else
                    sentBytes[0] = (byte)(sentBytes[0] & 253);
                myFtdiDevice.Write(sentBytes, 1, ref receivedBytes);
            }
    
            private void checkBox3_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox3.Checked)
                    sentBytes[0] = (byte)(sentBytes[0] | 4);
                else
                    sentBytes[0] = (byte)(sentBytes[0] & 251);
                myFtdiDevice.Write(sentBytes, 1, ref receivedBytes);
            }
    
            private void checkBox4_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox4.Checked)
                    sentBytes[0] = (byte)(sentBytes[0] | 8);
                else
                    sentBytes[0] = (byte)(sentBytes[0] & 247);
                myFtdiDevice.Write(sentBytes, 1, ref receivedBytes);
            }
    
            private void checkBox5_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox5.Checked)
                    sentBytes[0] = (byte)(sentBytes[0] | 16);
                else
                    sentBytes[0] = (byte)(sentBytes[0] & 239);
                myFtdiDevice.Write(sentBytes, 1, ref receivedBytes);
            }
    
            private void checkBox6_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox6.Checked)
                    sentBytes[0] = (byte)(sentBytes[0] | 32);
                else
                    sentBytes[0] = (byte)(sentBytes[0] & 223);
                myFtdiDevice.Write(sentBytes, 1, ref receivedBytes);
            }
    
            private void checkBox7_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox7.Checked)
                    sentBytes[0] = (byte)(sentBytes[0] | 64);
                else
                    sentBytes[0] = (byte)(sentBytes[0] & 191);
                myFtdiDevice.Write(sentBytes, 1, ref receivedBytes);
            }
    
            private void checkBox8_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox8.Checked)
                    sentBytes[0] = (byte)(sentBytes[0] | 128);
                else
                    sentBytes[0] = (byte)(sentBytes[0] & 127);
                myFtdiDevice.Write(sentBytes, 1, ref receivedBytes);
            }
        }
    }
    
    
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

saint1000 hasn't added any friends yet.

Comments

saint1000 has no profile comments yet. Why not say hello?