PDA

View Full Version : VB code to check data and change if true/false etc



stildawn
02-11-2013, 05:51 PM
Hi All

I am trying to come up with a VB macro to run in a freight system called Millman (Reflectio for Unix).

It has a record Macro function which you can then open to edit in VB.

I have generated this code using the record function:

With Session
.Transmit "b"
.StatusBar = "Waiting for Prompt: ³ MOD6225 18.00 69.840 IBRUN B"
.WaitForString ESC & "[C", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
.Transmit "e"
.StatusBar = "Waiting for Prompt: ³ MOD6225 18.00 69.840 IBRUN BE"
.WaitForString ESC & "[C", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
' Press CursorDown (Move the cursor down one line).
.TransmitTerminalKey rcVtDownKey
.StatusBar = "Waiting for Prompt: ³ DSRCD463100S 1.00 82.810 IBRUN"
.WaitForString ESC & "[9;65H", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
.Transmit "b"
.StatusBar = "Waiting for Prompt: ³ DSRCD463100S 1.00 82.810 IBRUN B"
.WaitForString ESC & "[C", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
.Transmit "e"
.StatusBar = "Waiting for Prompt: ³ DSRCD463100S 1.00 82.810 IBRUN BE"
.WaitForString ESC & "[C", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
' Press CursorDown (Move the cursor down one line).
.TransmitTerminalKey rcVtDownKey
' .WaitForString ESC & "[10;65H", NEVER_TIME_OUT, rcAllowKeystrokes
Exit Sub


Basically this is started in a field, I want a code that will check this field to see if it has a certain value (specifically in this case I want to check if there is "NQ" in that field, I then want it to change the data in the field to something else (in this case "AU") if it finds the specific data (the "NQ")

In the above code its simply putting in "BE" then pushing the down key, so instead of putting "BE" I would like the code to check the field and change as I said above, and then push down key.

Any ideas?

I could do this easily in excel, but in this program I am limited to pure VB editing.

Cheers