Skip to main content
Commonmark migration
Source Link

#Naming: Hungarian Notation is the DEVIL. ###It makes the reader want to see your code burn in eternal flames.

Naming: Hungarian Notation is the DEVIL.

It makes the reader want to see your code burn in eternal flames.

enter image description here

 

https://simpsonswiki.com/wiki/Flanders_the_Devil

  • objExcel would be better off as xlApp or excelApp
  • objUser is dying to call itself something like adUser
  • intRow wants to be called xlRow or just row
  • intUAC is silently begging for a more descriptive name
  • objOU wants to shoot whoever named it that

Now, whether your code is correct or not is off-topic for this site; since this question hasn't been closed as off-topic yet, I'm going to assume you've got working code.

Do Until objExcel.Cells(intRow,1).Value = ""

I'd use vbNullString here instead of "". It makes the intent clearer, and the non-string takes up 0 bytes. "" eats 6 bytes for no reason - StrPtr(vbNullString) is 0; StrPtr("") is a non-zero memory address.

The repeated assignments on objUser are a missed opportunity of using a With block:

With objOU.Create("User", "cn=" & objExcel.Cells(intRow, 3).Value, _
                          objExcel.Cells(intRow, 2).Value, _
                          objExcel.Cells(intRow, 19).Value)

    .SAMAccountName = objExcel.Cells(intRow, 19).Value & ".sat"
    .GivenName = objExcel.Cells(intRow, 3).Value
    .SN = objExcel.Cells(intRow, 2).Value
    .AccountDisabled = False
    .AccountExpirationDate = Date + 365
    '...

End With

Your usage of line continuation characters is... well, you use it in weird places. Actually, everywhere you've used it, I wouldn't have. Notice in the above snippet, how I used it to line up the parameters.

#Naming: Hungarian Notation is the DEVIL. ###It makes the reader want to see your code burn in eternal flames.

enter image description here

 

https://simpsonswiki.com/wiki/Flanders_the_Devil

  • objExcel would be better off as xlApp or excelApp
  • objUser is dying to call itself something like adUser
  • intRow wants to be called xlRow or just row
  • intUAC is silently begging for a more descriptive name
  • objOU wants to shoot whoever named it that

Now, whether your code is correct or not is off-topic for this site; since this question hasn't been closed as off-topic yet, I'm going to assume you've got working code.

Do Until objExcel.Cells(intRow,1).Value = ""

I'd use vbNullString here instead of "". It makes the intent clearer, and the non-string takes up 0 bytes. "" eats 6 bytes for no reason - StrPtr(vbNullString) is 0; StrPtr("") is a non-zero memory address.

The repeated assignments on objUser are a missed opportunity of using a With block:

With objOU.Create("User", "cn=" & objExcel.Cells(intRow, 3).Value, _
                          objExcel.Cells(intRow, 2).Value, _
                          objExcel.Cells(intRow, 19).Value)

    .SAMAccountName = objExcel.Cells(intRow, 19).Value & ".sat"
    .GivenName = objExcel.Cells(intRow, 3).Value
    .SN = objExcel.Cells(intRow, 2).Value
    .AccountDisabled = False
    .AccountExpirationDate = Date + 365
    '...

End With

Your usage of line continuation characters is... well, you use it in weird places. Actually, everywhere you've used it, I wouldn't have. Notice in the above snippet, how I used it to line up the parameters.

Naming: Hungarian Notation is the DEVIL.

It makes the reader want to see your code burn in eternal flames.

enter image description here

https://simpsonswiki.com/wiki/Flanders_the_Devil

  • objExcel would be better off as xlApp or excelApp
  • objUser is dying to call itself something like adUser
  • intRow wants to be called xlRow or just row
  • intUAC is silently begging for a more descriptive name
  • objOU wants to shoot whoever named it that

Now, whether your code is correct or not is off-topic for this site; since this question hasn't been closed as off-topic yet, I'm going to assume you've got working code.

Do Until objExcel.Cells(intRow,1).Value = ""

I'd use vbNullString here instead of "". It makes the intent clearer, and the non-string takes up 0 bytes. "" eats 6 bytes for no reason - StrPtr(vbNullString) is 0; StrPtr("") is a non-zero memory address.

The repeated assignments on objUser are a missed opportunity of using a With block:

With objOU.Create("User", "cn=" & objExcel.Cells(intRow, 3).Value, _
                          objExcel.Cells(intRow, 2).Value, _
                          objExcel.Cells(intRow, 19).Value)

    .SAMAccountName = objExcel.Cells(intRow, 19).Value & ".sat"
    .GivenName = objExcel.Cells(intRow, 3).Value
    .SN = objExcel.Cells(intRow, 2).Value
    .AccountDisabled = False
    .AccountExpirationDate = Date + 365
    '...

End With

Your usage of line continuation characters is... well, you use it in weird places. Actually, everywhere you've used it, I wouldn't have. Notice in the above snippet, how I used it to line up the parameters.

replaced http://simpsonswiki.com/ with https://simpsonswiki.com/
Source Link

#Naming: Hungarian Notation is the DEVIL. ###It makes the reader want to see your code burn in eternal flames.

http://simpsonswiki.com/w/images/7/7c/Devil_Flanders.pngenter image description here

http://simpsonswiki.com/wiki/Flanders_the_Devilhttps://simpsonswiki.com/wiki/Flanders_the_Devil

  • objExcel would be better off as xlApp or excelApp
  • objUser is dying to call itself something like adUser
  • intRow wants to be called xlRow or just row
  • intUAC is silently begging for a more descriptive name
  • objOU wants to shoot whoever named it that

Now, whether your code is correct or not is off-topic for this site; since this question hasn't been closed as off-topic yet, I'm going to assume you've got working code.

Do Until objExcel.Cells(intRow,1).Value = ""

I'd use vbNullString here instead of "". It makes the intent clearer, and the non-string takes up 0 bytes. "" eats 6 bytes for no reason - StrPtr(vbNullString) is 0; StrPtr("") is a non-zero memory address.

The repeated assignments on objUser are a missed opportunity of using a With block:

With objOU.Create("User", "cn=" & objExcel.Cells(intRow, 3).Value, _
                          objExcel.Cells(intRow, 2).Value, _
                          objExcel.Cells(intRow, 19).Value)

    .SAMAccountName = objExcel.Cells(intRow, 19).Value & ".sat"
    .GivenName = objExcel.Cells(intRow, 3).Value
    .SN = objExcel.Cells(intRow, 2).Value
    .AccountDisabled = False
    .AccountExpirationDate = Date + 365
    '...

End With

Your usage of line continuation characters is... well, you use it in weird places. Actually, everywhere you've used it, I wouldn't have. Notice in the above snippet, how I used it to line up the parameters.

#Naming: Hungarian Notation is the DEVIL. ###It makes the reader want to see your code burn in eternal flames.

http://simpsonswiki.com/w/images/7/7c/Devil_Flanders.png

http://simpsonswiki.com/wiki/Flanders_the_Devil

  • objExcel would be better off as xlApp or excelApp
  • objUser is dying to call itself something like adUser
  • intRow wants to be called xlRow or just row
  • intUAC is silently begging for a more descriptive name
  • objOU wants to shoot whoever named it that

Now, whether your code is correct or not is off-topic for this site; since this question hasn't been closed as off-topic yet, I'm going to assume you've got working code.

Do Until objExcel.Cells(intRow,1).Value = ""

I'd use vbNullString here instead of "". It makes the intent clearer, and the non-string takes up 0 bytes. "" eats 6 bytes for no reason - StrPtr(vbNullString) is 0; StrPtr("") is a non-zero memory address.

The repeated assignments on objUser are a missed opportunity of using a With block:

With objOU.Create("User", "cn=" & objExcel.Cells(intRow, 3).Value, _
                          objExcel.Cells(intRow, 2).Value, _
                          objExcel.Cells(intRow, 19).Value)

    .SAMAccountName = objExcel.Cells(intRow, 19).Value & ".sat"
    .GivenName = objExcel.Cells(intRow, 3).Value
    .SN = objExcel.Cells(intRow, 2).Value
    .AccountDisabled = False
    .AccountExpirationDate = Date + 365
    '...

End With

Your usage of line continuation characters is... well, you use it in weird places. Actually, everywhere you've used it, I wouldn't have. Notice in the above snippet, how I used it to line up the parameters.

#Naming: Hungarian Notation is the DEVIL. ###It makes the reader want to see your code burn in eternal flames.

enter image description here

https://simpsonswiki.com/wiki/Flanders_the_Devil

  • objExcel would be better off as xlApp or excelApp
  • objUser is dying to call itself something like adUser
  • intRow wants to be called xlRow or just row
  • intUAC is silently begging for a more descriptive name
  • objOU wants to shoot whoever named it that

Now, whether your code is correct or not is off-topic for this site; since this question hasn't been closed as off-topic yet, I'm going to assume you've got working code.

Do Until objExcel.Cells(intRow,1).Value = ""

I'd use vbNullString here instead of "". It makes the intent clearer, and the non-string takes up 0 bytes. "" eats 6 bytes for no reason - StrPtr(vbNullString) is 0; StrPtr("") is a non-zero memory address.

The repeated assignments on objUser are a missed opportunity of using a With block:

With objOU.Create("User", "cn=" & objExcel.Cells(intRow, 3).Value, _
                          objExcel.Cells(intRow, 2).Value, _
                          objExcel.Cells(intRow, 19).Value)

    .SAMAccountName = objExcel.Cells(intRow, 19).Value & ".sat"
    .GivenName = objExcel.Cells(intRow, 3).Value
    .SN = objExcel.Cells(intRow, 2).Value
    .AccountDisabled = False
    .AccountExpirationDate = Date + 365
    '...

End With

Your usage of line continuation characters is... well, you use it in weird places. Actually, everywhere you've used it, I wouldn't have. Notice in the above snippet, how I used it to line up the parameters.

deleted 9 characters in body
Source Link
Mathieu Guindon
  • 75.6k
  • 18
  • 194
  • 468

#Naming: Hungarian Notation is the DEVIL. ###It makes the reader want to see your code burn in eternal flames.

http://simpsonswiki.com/w/images/7/7c/Devil_Flanders.png

http://simpsonswiki.com/wiki/Flanders_the_Devil

  • objExcel would be better off as xlApp or excelApp
  • objUser is dying to call itself something like adUser
  • intRow wants to be called xlRow or just row
  • intUAC is silently begging for a more descriptive name
  • objOU wants to shoot whoever named it that

Now, whether your code is correct or not is off-topic for this site; since this question hasn't been closed as off-topic yet, I'm going to assume you've got working code.

Do Until objExcel.Cells(intRow,1).Value = ""

I'd use vbNullString here instead of "". It makes the intent clearer, and the non-string takes up 0 bytes. "" eats 6 bytes for no reason - StrPtr(vbNullString) is 0; StrPtr("") is a non-zero memory address.

The repeated assignments on objUser are a missed opportunity of using a With block:

With objOU.Create("User", "cn=" & objExcel.Cells(intRow, 3).Value, _
                          objExcel.Cells(intRow, 2).Value, _
                          objExcel.Cells(intRow, 19).Value)

    .SAMAccountName = objExcel.Cells(intRow, 19).Value & ".sat"
    .GivenName = objExcel.Cells(intRow, 3).Value
    .SN = objExcel.Cells(intRow, 2).Value
    .AccountDisabled = False
    .AccountExpirationDate = Date + 365
    '...

End With

Your usage of line continuation characters is... well, you use it in weird places. Actually, everywhere you've used it, I wouldn't have. Notice in the above snippet, how I used indentationit to line up the parameters.

#Naming: Hungarian Notation is the DEVIL. ###It makes the reader want to see your code burn in eternal flames.

http://simpsonswiki.com/w/images/7/7c/Devil_Flanders.png

http://simpsonswiki.com/wiki/Flanders_the_Devil

  • objExcel would be better off as xlApp or excelApp
  • objUser is dying to call itself something like adUser
  • intRow wants to be called xlRow or just row
  • intUAC is silently begging for a more descriptive name
  • objOU wants to shoot whoever named it that

Now, whether your code is correct or not is off-topic for this site; since this question hasn't been closed as off-topic yet, I'm going to assume you've got working code.

Do Until objExcel.Cells(intRow,1).Value = ""

I'd use vbNullString here instead of "". It makes the intent clearer, and the non-string takes up 0 bytes. "" eats 6 bytes for no reason - StrPtr(vbNullString) is 0; StrPtr("") is a non-zero memory address.

The repeated assignments on objUser are a missed opportunity of using a With block:

With objOU.Create("User", "cn=" & objExcel.Cells(intRow, 3).Value, _
                          objExcel.Cells(intRow, 2).Value, _
                          objExcel.Cells(intRow, 19).Value)

    .SAMAccountName = objExcel.Cells(intRow, 19).Value & ".sat"
    .GivenName = objExcel.Cells(intRow, 3).Value
    .SN = objExcel.Cells(intRow, 2).Value
    .AccountDisabled = False
    .AccountExpirationDate = Date + 365
    '...

End With

Your usage of line continuation characters is... well, you use it in weird places. Actually, everywhere you've used it, I wouldn't have. Notice in the above snippet, how I used indentation to line up the parameters.

#Naming: Hungarian Notation is the DEVIL. ###It makes the reader want to see your code burn in eternal flames.

http://simpsonswiki.com/w/images/7/7c/Devil_Flanders.png

http://simpsonswiki.com/wiki/Flanders_the_Devil

  • objExcel would be better off as xlApp or excelApp
  • objUser is dying to call itself something like adUser
  • intRow wants to be called xlRow or just row
  • intUAC is silently begging for a more descriptive name
  • objOU wants to shoot whoever named it that

Now, whether your code is correct or not is off-topic for this site; since this question hasn't been closed as off-topic yet, I'm going to assume you've got working code.

Do Until objExcel.Cells(intRow,1).Value = ""

I'd use vbNullString here instead of "". It makes the intent clearer, and the non-string takes up 0 bytes. "" eats 6 bytes for no reason - StrPtr(vbNullString) is 0; StrPtr("") is a non-zero memory address.

The repeated assignments on objUser are a missed opportunity of using a With block:

With objOU.Create("User", "cn=" & objExcel.Cells(intRow, 3).Value, _
                          objExcel.Cells(intRow, 2).Value, _
                          objExcel.Cells(intRow, 19).Value)

    .SAMAccountName = objExcel.Cells(intRow, 19).Value & ".sat"
    .GivenName = objExcel.Cells(intRow, 3).Value
    .SN = objExcel.Cells(intRow, 2).Value
    .AccountDisabled = False
    .AccountExpirationDate = Date + 365
    '...

End With

Your usage of line continuation characters is... well, you use it in weird places. Actually, everywhere you've used it, I wouldn't have. Notice in the above snippet, how I used it to line up the parameters.

Source Link
Mathieu Guindon
  • 75.6k
  • 18
  • 194
  • 468
Loading