+ Post New Thread
Results 1 to 10 of 10
Coding Thread, VB For Idiots in Coding and Web Development; Anyone know where I can find some idiot proof VB instructions, usage, learning examples? Need to create a few VB ...
  1. #1
    ahuxham's Avatar
    Join Date
    Apr 2008
    Posts
    1,122
    Thank Post
    76
    Thanked 138 Times in 109 Posts
    Rep Power
    30

    VB For Idiots

    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?

    Code:
    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.

  2. #2

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,766
    Thank Post
    3,274
    Thanked 1,053 Times in 974 Posts
    Rep Power
    365
    vb 6, vb dot net ( if vb dot net then which version )

  3. #3
    ahuxham's Avatar
    Join Date
    Apr 2008
    Posts
    1,122
    Thank Post
    76
    Thanked 138 Times in 109 Posts
    Rep Power
    30
    Quote Originally Posted by mac_shinobi View Post
    vb 6, vb dot net ( if vb dot net then which version )
    Plain old VB6

  4. #4

    Join Date
    May 2008
    Location
    Cheshire
    Posts
    292
    Thank Post
    48
    Thanked 27 Times in 24 Posts
    Rep Power
    18
    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

    :-)

  5. #5
    ahuxham's Avatar
    Join Date
    Apr 2008
    Posts
    1,122
    Thank Post
    76
    Thanked 138 Times in 109 Posts
    Rep Power
    30
    Quote Originally Posted by Pashers View Post
    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.

  6. #6

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,766
    Thank Post
    3,274
    Thanked 1,053 Times in 974 Posts
    Rep Power
    365
    Quote Originally Posted by ahuxham View Post
    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 ?

  7. #7

    Join Date
    May 2008
    Location
    Cheshire
    Posts
    292
    Thank Post
    48
    Thanked 27 Times in 24 Posts
    Rep Power
    18
    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)

    Code:
    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

  8. #8
    ahuxham's Avatar
    Join Date
    Apr 2008
    Posts
    1,122
    Thank Post
    76
    Thanked 138 Times in 109 Posts
    Rep Power
    30
    Quote Originally Posted by Pashers View Post
    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)

    Code:
    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 :P

  9. #9

    Join Date
    May 2008
    Location
    Cheshire
    Posts
    292
    Thank Post
    48
    Thanked 27 Times in 24 Posts
    Rep Power
    18
    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?

  10. #10
    ahuxham's Avatar
    Join Date
    Apr 2008
    Posts
    1,122
    Thank Post
    76
    Thanked 138 Times in 109 Posts
    Rep Power
    30
    Quote Originally Posted by Pashers View Post
    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

SHARE:
+ Post New Thread

Similar Threads

  1. Idiots Guide .... please!!
    By brahma in forum O/S Deployment
    Replies: 3
    Last Post: 15th October 2008, 03:30 PM
  2. [Video] IT Guy vs Idiots
    By Geoff in forum Jokes/Interweb Things
    Replies: 3
    Last Post: 4th July 2008, 03:17 PM
  3. IT Idiots
    By GrumbleDook in forum Courses and Training
    Replies: 46
    Last Post: 15th December 2007, 09:06 PM
  4. For you idiots hehe
    By intrigue in forum General Chat
    Replies: 1
    Last Post: 23rd September 2005, 07:36 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •