Page 1 of 3 123 LastLast
Results 1 to 12 of 26

Thread: Text Boxes

  1. #1
    Registered
    Join Date
    Jun 2005
    Location
    USA
    Posts
    180
    Downloads
    0
    Uploads
    0

    Text Boxes

    I am converting some of my Excel VB programs into VB Express. I generally have a lot of inputs, and generate GCode from those inputs

    Is there any way in VB Express to get that information without using textbox1, textbox2, etc? (like textbox(n), and using a loop to index in each time)

    The reason I want to do this -- and maybe there is a better way than a textbox -- is I have a form that has 3 columns for x, y, z values indicating where I want to drill a hole. There could be 1 or up to 100 rows of x,y,z values. I would like to step through one row at a time until there are no more values on the row, then exit the program. I would like to do this without having to type in code for textbox1 to textbox100.


  2. #2
    Registered bradodarb's Avatar
    Join Date
    Oct 2004
    Location
    usa
    Posts
    147
    Downloads
    0
    Uploads
    0
    Try an array.


  3. #3
    Registered
    Join Date
    Jun 2005
    Location
    USA
    Posts
    180
    Downloads
    0
    Uploads
    0
    How do you change the textbox name to indicate it is an array?


  4. #4
    Registered ghyman's Avatar
    Join Date
    Feb 2005
    Location
    USA
    Posts
    221
    Downloads
    0
    Uploads
    0
    "maybe there is a better way than a textbox"

    Textbox arrays are easy to use, but potentially make for a LOT of code.

    I'm not sure I understand your project... You have a form with 3 columns of x,y,and (or) z coordinates. Like this?

    X1 Y3 Z-2
    X2 Z-1.5
    X1 Y4

    And you want to read one line at a time, and do... what?

    If you already have the data in some format that can be saved in text format, then it's pretty easy to read the data in one line at a time:

    Open "filename.txt" for input as #1
    while eof(1)<>-1
    line input #1,a$
    *** do stuff ***
    wend


    If I knew more about what you wanted to do with the data, I could be a little more helpful.


  • #5
    Registered
    Join Date
    Jun 2005
    Location
    USA
    Posts
    180
    Downloads
    0
    Uploads
    0
    That's close. The form looks like this:

    X.........Y...........Z <<< Label for columns
    1.5 .......2........3.5 <<< Row 1, three textboxes for input
    2.........2.5........4 <<< Row 2
    etc.

    I have several "generic" GCode generators -- each read from an input form and write GCode to an output file for simple operations.

    The one above is for a drill pattern. The program reads Row 1, and writes Gcode to send the mill to the Row 1 X,Y position at a safe Z, then moves to the Row 1 Z value and retracts to a safe Z. The program then moves to row 2 and does the same thing. When there is a blank row, the program stops, and closes the GCode file.

    What you show above is reading from an external file. I want to read the user input from the VB form (there is no external file at this point).


  • #6
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Twp, MI....USA
    Posts
    22,303
    Downloads
    0
    Uploads
    0
    I'd use one row of text boxes and store the data in an array. Store the data as it's entered. Use a forward and back button to cycle through the array.
    Gerry

    Mach3 2010 Screenset
    http://home.comcast.net/~cncwoodworker/2010.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  • #7
    Registered
    Join Date
    Jun 2005
    Location
    USA
    Posts
    180
    Downloads
    0
    Uploads
    0
    Thanks for the inputs.

    I would like to see all of the inputs at once, and be able to change any of them. You could do that with a single set of boxes, but I think typing in TextBox1 to TextBox100 will be easier in the long run -- and I probably will not go to 100 to make it easier.


  • #8
    Registered
    Join Date
    Aug 2005
    Location
    U.S.A
    Posts
    52
    Downloads
    0
    Uploads
    0
    I agree, a lot of text boxes would be a pain.

    3 boxes per row (x, y, z) and 100 rows = 300 text boxes

    I think you could do this with one multiline text box. You could use a comma delimited data entry method with line feeds. See attached file

    The "SPLIT" function in VB could be used to break the text box multiline text into the x, y, and z locations. The "SPLIT" function can also find a new line using the ASCII character 10 and 13 for carriage return and line feed.

    Another way of making the manual data entry easier would be to use Microsoft Excel. Use the spreadsheet's columns for the X, Y, and Z data. Of course, the spreadsheet's rows contain the individual Drill file position.

    You could then take the Excel spreadsheet and write an excel macro to convert this data into a Gcode CNC file or save it as a Comma Delimited text file. The Comma Delimited text file would need to be converted into Gcode using VB.
    Attached Thumbnails Attached Thumbnails Text Boxes-cnczone_help.jpg  


  • #9
    Registered
    Join Date
    Jun 2005
    Location
    USA
    Posts
    180
    Downloads
    0
    Uploads
    0
    Thanks. I actually have an Excel spreadsheet that does exactly that, but was hoping to duplicate it in VB Express.


  • #10
    Registered
    Join Date
    Aug 2005
    Location
    U.S.A
    Posts
    52
    Downloads
    0
    Uploads
    0
    How about a list box, three text boxes, and three command buttons. The List Box shows all of your manual entry cooridinates in a comma or tab delimited format, Example (0.001 9.0123 5.002). You can scroll through the list and select a row. When you select a row of data the X, Y, Z data appears in the three text boxes for editing. The three command buttons could ADD, UPDATE, or DELETE the current selected row of data in the List Box. The default selected row could always be the last row in the list. Therefore, if you click the ADD button it will always add the data to the end of you List Box. When your done, I suppose you will need a "Generate GCODE" button or menu option.


  • #11
    Registered
    Join Date
    Jul 2005
    Location
    USA
    Posts
    21
    Downloads
    0
    Uploads
    0
    rweatherly,

    Does the Express version let you add controls/components? For example, normal VB 6 allows you to add controls/components (with Ctrl-T). There are some "Microsoft Windows Common Controls" in mscomctl.ocx, mscomct2.ocx, etc that you may want to look at. Somewhere there is a grid control if you were longing for the Excel look and feel. A google search may turn up a grid-control that you could download for cheap or free.

    Otherwise, I like Megahertz suggestion. I think it would be a good interface and you could always add a right-click "import" and "export" command to deal with text files later on.


  • #12
    Registered
    Join Date
    Jul 2003
    Location
    New Zealand
    Posts
    1,137
    Downloads
    0
    Uploads
    0
    rweatherly
    Here is some VB6 code which will read a Excel file when the data is in columns : X figure in Column A: Y figure in B: Z figure in C, and paste into a textbox in your VB program.
    This may help to get you started with VB Express if this is what you require.
    Pics show the data in Excel and the VB text box which can be scrolled.

    Private Sub Command1_Click()
    Dim xlApp As Excel.Application
    Dim xlBook1 As Workbook
    Dim xlSheet1 As Worksheet
    Set xlApp = Excel.Application

    Dim strX As String
    Dim strY As String
    Dim strZ As String
    Dim strLine As String
    Dim strACell As String
    Dim strBCell As String
    Dim strCCell As String

    FileName = "C:\TestXYZ2TextBox\Book1.xls"
    Set xlBook1 = xlApp.Workbooks.Open(FileName)
    xlApp.Application.ScreenUpdating = True
    'xlApp.Visible = True

    For L = 2 To 10
    strLine = L
    strX = "": strY = "": strZ = ""

    strACell = Chr$(65) + strLine
    Range(strACell).Select
    strX = CStr(ActiveCell.Value)

    strBCell = Chr$(66) + strLine
    Range(strBCell).Select
    strY = CStr(ActiveCell.Value)

    strCCell = Chr$(67) + strLine
    Range(strCCell).Select
    strZ = CStr(ActiveCell.Value)

    strData = strData & "X" & strX & " Y" & strY & " Z" & strZ & Chr$(13) & Chr$(10)
    Next

    txtData.Text = strData

    End Sub
    Attached Thumbnails Attached Thumbnails Text Boxes-screen2.jpg   Text Boxes-screen1.jpg  
    Last edited by Kiwi; 01-02-2007 at 06:26 AM.


  • Page 1 of 3 123 LastLast

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.