ahuxham Posted July 13, 2009 Posted July 13, 2009 Anyone know where I can find some idiot proof VB instructions, usage, learning examples? Need to create a few VB actions for a project I'm currently working on, and have no idea where to start, The main functions I'd need to look at are; 1) If field begins with XX use the last 18 digits of the field. 2) Calculate day names based on dates. (If 12/07/2009 output Sunday) 3) Finally; Text replacement, if text = 123, replace with 345 but allowing for multiple text pieces. I.e. 123, 321, 132 etc So Text replacement, Date/Time Calculations, and If statements? Better examples; 1) If field begins with DH, copy 002001001001001001 and use that data, ignore the rest. DP 001001001001001001 DH 002001001001001001 DZ 003001001001001001 2) As it says on the tin, if date = 12/07/2009 calculate day name and output 3) Simple text replacement I guess, however not sure what functions to read up on; DF CFE (If CFE output with text Coffee) DF MNK (If MNK output with text Monkey) DF HS (If HS output with text House) etc Many thanks for any help, pointers or links provided folks, really struggling, and don't really want to learn alot of VB just to accomplish the above. Cheers.
mac_shinobi Posted July 13, 2009 Posted July 13, 2009 vb 6, vb dot net ( if vb dot net then which version )
ahuxham Posted July 13, 2009 Author Posted July 13, 2009 vb 6, vb dot net ( if vb dot net then which version ) Plain old VB6
Pashers Posted July 13, 2009 Posted July 13, 2009 If you're looking at vb (any version) You'll obviously need to learn how to read the data (it looks to me like sql). VB has a function called day so Day(Now()) will display today's day. Note Now() is a function to return the date today. You also have Month(...) and Year(...) If you have a string "hello world" replace world with "there" you can use this function: strHello = "hello world!" strResult = Replace(strHello,"world","there") strResult now is equal to "hello there" If you need any more help give a shout :-)
ahuxham Posted July 13, 2009 Author Posted July 13, 2009 If you're looking at vb (any version) You'll obviously need to learn how to read the data (it looks to me like sql). VB has a function called day so Day(Now()) will display today's day. Note Now() is a function to return the date today. You also have Month(...) and Year(...) If you have a string "hello world" replace world with "there" you can use this function: strHello = "hello world!" strResult = Replace(strHello,"world","there") strResult now is equal to "hello there" If you need any more help give a shout :-) Awesome, got the replacement part there. The data isn't SQL, its around 100,000-500,000 flat text files, encoded ANSI and varying in size between 11kb and 918kb. Need to pull majority of the data from the text files and print it in another program, however since the program doesn't understand what position limited files are it ignores what I need to select. Hence the "Selecting "string" if it matches field description" Would have to create three different VB scripts. 1) Select data only if in row DH for example and replace the data with another word, as the data is shortcode 2) Select data only if in row DH for example, calculate the date and show the Day 3)Select data only if in row DH for example, and show the data in column I confuse myself at times.
mac_shinobi Posted July 13, 2009 Posted July 13, 2009 Awesome, got the replacement part there. The data isn't SQL, its around 100,000-500,000 flat text files, encoded ANSI and varying in size between 11kb and 918kb. Need to pull majority of the data from the text files and print it in another program, however since the program doesn't understand what position limited files are it ignores what I need to select. Hence the "Selecting "string" if it matches field description" Would have to create three different VB scripts. 1) Select data only if in row DH for example and replace the data with another word, as the data is shortcode 2) Select data only if in row DH for example, calculate the date and show the Day 3)Select data only if in row DH for example, and show the data in column I confuse myself at times. Can you copy and paste a short snippet of the data into a post and then explain it that way using the posted snippet and explaining what you want to do in each step ?
Pashers Posted July 14, 2009 Posted July 14, 2009 I think I grasp the basic concept of what you're trying to do. Here's some code it's been a long time since I've done VB 6 (I've not checked for errors) Open "textfile.txt" #1 Do Until EOF(1) Line Input #1 , strLine If Left(strLine,2)="DH" Then Replace(strLine, "CurrentWord", "ReplacementWord") ... ... End If Loop Without any data I won't be able to give much more help
ahuxham Posted July 14, 2009 Author Posted July 14, 2009 I think I grasp the basic concept of what you're trying to do. Here's some code it's been a long time since I've done VB 6 (I've not checked for errors) Open "textfile.txt" #1 Do Until EOF(1) Line Input #1 , strLine If Left(strLine,2)="DH" Then Replace(strLine, "CurrentWord", "ReplacementWord") ... ... End If Loop Without any data I won't be able to give much more help Example data is here: pastebin - collaborative debugging tool I replace DH with CH for argument sake and integrity of the document
Pashers Posted July 14, 2009 Posted July 14, 2009 I can't see any dates in there?! The previous code snippet will bring up this line for example. DH 5000119000006 1425800 5034139000001 Name Name How would you want this to be modified?
ahuxham Posted July 14, 2009 Author Posted July 14, 2009 I can't see any dates in there?! The previous code snippet will bring up this line for example. DH 5000119000006 1425800 5034139000001 Name Name How would you want this to be modified? Changed the original DH to CH, the information would show as: CH RHHNIN 5028591000402 Name 1796525 081029 081030 0000 1201 5028591000402 Would like to replace RHHNIN with a full name, depending on what I set as its replacement word, and RHHNO as something else for example. The date is there, its just hidden-ish, the date is always start position 130 on the CH line. In the above example this would be 30th October 2008 as 081030
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now