-Поиск по дневнику

Поиск сообщений в rss_thedaily_wtf

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 06.04.2008
Записей:
Комментариев:
Написано: 0


CodeSOD: Without Any Padding

Вторник, 27 Июля 2021 г. 09:30 + в цитатник

Years ago, Aleshia W started a job in a VB.Net shop. There's a lot I could say about those kinds of environments, but I'd really just be padding out the article, so let's just get right to the code- which pads out a Year string.

Protected Function YearPadText(ByVal val As String) As String Dim valLen As Integer valLen = val.Len Select Case valLen Case 1 val = val + " " Case 2 val = val + " " Case 3 val = val + " " Case 4 val = val + " " Case 5 val = val + " " Case 6 val = val + " " Case 7 val = val + " " Case 8 val = val + " " Case 9 val = val + " " Case 10 val = val + " " Case 11 val = val + " " Case 12 val = val + " " Case 13 val = val + " " Case 14 val = val + " " End Select Return val End Function

You'll be unsurprised to learn that VB.Net has several different built-in ways of accomplishing this task, rendering this code unnecessary. One could complain that this code doesn't handle the situation when a year string is longer than 15 characters, but that raises a question: why would your year string be longer than 15 characters?

[Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. Get started with Otter today!

https://thedailywtf.com/articles/without-any-padding

Метки:  

 

Добавить комментарий:
Текст комментария: смайлики

Проверка орфографии: (найти ошибки)

Прикрепить картинку:

 Переводить URL в ссылку
 Подписаться на комментарии
 Подписать картинку