CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > Visual Basic


Visual Basic Discuss Visual Basic programing.


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 12-11-2006, 03:21 PM
 
Join Date: Jun 2005
Location: USA
Posts: 180
rweatherly is on a distinguished road
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.
Tweet this Post!Share on Facebook
Reply With Quote

  #2   Ban this user!
Old 12-12-2006, 01:21 AM
bradodarb's Avatar  
Join Date: Oct 2004
Location: usa
Posts: 121
bradodarb is on a distinguished road

Try an array.
Tweet this Post!Share on Facebook
Reply With Quote

  #3   Ban this user!
Old 12-12-2006, 08:01 AM
 
Join Date: Jun 2005
Location: USA
Posts: 180
rweatherly is on a distinguished road

How do you change the textbox name to indicate it is an array?
Tweet this Post!Share on Facebook
Reply With Quote

  #4   Ban this user!
Old 12-12-2006, 08:56 AM
ghyman's Avatar  
Join Date: Feb 2005
Location: USA
Posts: 214
ghyman is on a distinguished road

"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.
Tweet this Post!Share on Facebook
Reply With Quote

  #5   Ban this user!
Old 12-12-2006, 09:12 AM
 
Join Date: Jun 2005
Location: USA
Posts: 180
rweatherly is on a distinguished road

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).
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #6  
Old 12-12-2006, 09:23 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 19,570
ger21 is on a distinguished road
Buy me a Beer?

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)
Tweet this Post!Share on Facebook
Reply With Quote

  #7   Ban this user!
Old 12-12-2006, 10:19 AM
 
Join Date: Jun 2005
Location: USA
Posts: 180
rweatherly is on a distinguished road

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.
Tweet this Post!Share on Facebook
Reply With Quote

  #8   Ban this user!
Old 12-12-2006, 08:55 PM
 
Join Date: Aug 2005
Location: U.S.A
Posts: 52
Megahertz is on a distinguished road

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
Click image for larger version

Name:	CNCzone help.JPG‎
Views:	150
Size:	13.5 KB
ID:	27218  
Tweet this Post!Share on Facebook
Reply With Quote

  #9   Ban this user!
Old 12-12-2006, 11:10 PM
 
Join Date: Jun 2005
Location: USA
Posts: 180
rweatherly is on a distinguished road

Thanks. I actually have an Excel spreadsheet that does exactly that, but was hoping to duplicate it in VB Express.
Tweet this Post!Share on Facebook
Reply With Quote

  #10   Ban this user!
Old 12-13-2006, 12:47 PM
 
Join Date: Aug 2005
Location: U.S.A
Posts: 52
Megahertz is on a distinguished road

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.
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 01-01-2007, 08:05 PM
 
Join Date: Jul 2005
Location: USA
Age: 43
Posts: 21
HenryCNC is on a distinguished road

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.
Tweet this Post!Share on Facebook
Reply With Quote

  #12   Ban this user!
Old 01-02-2007, 05:51 AM
 
Join Date: Jul 2003
Location: New Zealand
Posts: 992
Kiwi is on a distinguished road

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
Click image for larger version

Name:	Screen2.JPG‎
Views:	136
Size:	86.5 KB
ID:	28379   Click image for larger version

Name:	Screen1.JPG‎
Views:	139
Size:	20.6 KB
ID:	28380  

Last edited by Kiwi; 01-02-2007 at 06:26 AM.
Tweet this Post!Share on Facebook
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -5. The time now is 01:11 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353