473,387 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VB, tab delimited input file and using it...

OK, I am going to preface this by saying I'm very new to VB coding (or any other kind, for that matter), but know a lot about Windows, AD and Security. We are making adjustments to our environment and someone needs to adjust our scripts. I've got a lot of the books and the information that I need to do some of the items is in there. I'm just trying to put it together.

Basically what I need to be able to do is run a script that reads a tab delimited file, parses the fields and then uses those fields to perform various functions (mattering on the script). If I can get the first one working, I think that the rest will be relatively elementary to adjust to do what I need them to do. This first snippet of code is HORRIBLE. I've been trying to get it working for ages now (ok... a week and a half, give or take... it just seems like ages), so I figure I'll ask some people who might be able to help me.

Expand|Select|Wrap|Line Numbers
  1. Module modUserCreation
  2.     Const ForReading = 1
  3.     Const ForWriting = 2
  4.     Const ForAppending = 8
  5.     Const TriStateUseDefault = -2
  6.     Public LogFilename
  7.     Public strprefix
  8.         Public Sub Main()
  9.             Dim strmsg As String
  10.             Dim x As Object
  11.             Dim struserid As String
  12.             Dim strfname As String
  13.             Dim strsname As String
  14.             Dim strminit As String
  15.             Dim strdname As String
  16.             Dim strdescr As String
  17.             Dim strcontainer As String
  18.             Dim strpaswd As String
  19.             Dim strdomain As String
  20.             Dim strdomainsuffix As String
  21.             Dim record As String
  22.             Dim strfilename As String
  23.  
  24.             strfilename = InputBox("Enter user list file name")
  25.             strdomain = InputBox("Enter Domain Name ex: Microsoft, Google")
  26.             strdomainsuffix = InputBox("Enter DNS suffix for domain ex: com, local")
  27.  
  28.             FileOpen(1, My.Application.Info.DirectoryPath & "\" & strfilename, OpenMode.Input)
  29.  
  30.             While Not EOF(1)
  31.                 record = LineInput(1)
  32.                 x = Split(record, vbTab)
  33.                 strcontainer = Trim(x(0)) 'This is the name of the OU that the user object will be created in
  34.                 struserid = Trim(x(1)) 'UserID (logon name) field - should validate before submitting, must be unique
  35.                 strfname = Trim(x(2)) 'User First Name
  36.                 strsname = Trim(x(3)) 'User Last (sur)Name
  37.                 strminit = Trim(x(4)) 'User Middle Initial
  38.                 strdname = Trim(x(5)) 'Display Name (probably want to create an option on order or fname, sname and minit
  39.                 strdescr = Trim(x(6)) 'Description field
  40.                 strpaswd = Trim(x(7)) 'Password - probably want to eventually turn this into a random typable set of characters
  41.  
  42.                 'Time to create the user with the fields pulled in from the text file (possibly pull the data from text input)                
  43.  
  44.                 objParent = strcontainer
  45.                 objUser = objParent.Create("user", "cn=" & struserid) 
  46.                 objUser.Put("sAMAccountName", struserid) 'Set sAMAccountName field
  47.                 objUser.Put("userPrincipalName", struserid & "@" & strdomain & "." & strdomainsuffix) 
  48.                 objUser.Put("givenName", strfname) 'First name
  49.                 objUser.Put("sn", strsname) 'surname
  50.                 objUser.Put("displayName", strsname & ", " & strfname & " " & strminit) 
  51.                 objUser.Put("mname", strminit)
  52.                 objUser.SetInfo()
  53.                 objUser.SetPassword(strpaswd)
  54.                 objUser.AccountDisabled = False
  55.                 objUser.SetInfo()
  56.                 objUser.Put("userAccountControl", 512)
  57.                 objUser.SetInfo()
  58.  
  59.  
  60.  
  61.             End While
  62.             FileClose(1)
  63.  
  64.         End Sub
  65.     End Class
  66. End Module

BTW... yes, I know I have some really boneheaded errors in here, I think some are the result of several edits accidentally removing required items.

I can create the user object when I explicitly define the variables (or provide input boxes), but when I try to do it with input from a file, it flakes out on me.
Nov 7 '07 #1
1 4327
Killer42
8,435 Expert 8TB
I don't get which part of this code you are actually asking for help with. What is happening or not happening, that shouldn't , or should?
Nov 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ben | last post by:
Hi all - I am having a bit of trouble and thought maybe someone in this group could shed some light. Here's the skinny... I am creating an automated process to import a bunch of text files...
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
1
by: bhups | last post by:
hi, i am doing a lookup using hash table. I have a pipe delimited file that i have to search for a new invocie number field by checking of an old invoice number-customer number key combination...
4
by: Karl | last post by:
How do you read a tab delimited text file? The file has 3 colums of data. I can read fixed width text files using the left and mid functions. I had rather not use transfer text and import specs.
2
by: Sheldon | last post by:
I'm using DoCmd.TransferText acImportDelim... to import a tab-delimited ..txt file using an Import Specification file and that works fine. The problem is that a few records could have...
1
by: Fordraiders | last post by:
vb.net 2003 Office 2003 What I have: C:\TestData\Input.txt Text File Pipe Delimited : 4 columns Of data example: 00001|NO BRAND NAME ASSIGNED|6DU27|M3-.5 X 6 FLAT HD SOCKET CAP SCREW,...
5
by: RyanL | last post by:
I'm a newbie! I have a non-delimited data file that I'd like to convert to delimited. Example... Line in non-delimited file: 0139725635999992000010100534+42050-102800FM-15+1198KAIA Should...
1
by: nick777 | last post by:
Hope the Community can bear with me as I muddle with the vocabulary since I am not really sure if I am going about this the correct way. My question is as follows: If I had some sample data in...
7
by: lancewassing | last post by:
I'm hoping this question is simple. I am trying to create a login script for my already in place client manage using php. I have created a text file filled with usernames and passwords delimited by...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.