Archive for the 'VB un .net' Category

Always, ALWAYS initialize!

Friday, October 20th, 2006

What output would you expect from such a piece of code (VB.net, of course): Imports System.Globalization …. Dim CurrentCalendar As System.Globalization.Calendar = _ CultureInfo.CurrentUICulture.Calendar ‘We want to [...]

IsUserInGroup updated

Thursday, May 11th, 2006

In an earlier article I’ve been talkin about how to check if a user belongs to a specific domain group. However, the code in that article doesn’t work on local groups and WinNT ADSI provider. I’ve made an update to the code posted there, this should work both on domain and local groups. Usage: If IsUserInGroup(”Contoso\JohnDoe”, “Contoso\Managers”) [...]

Does this user belong to that domain group?

Thursday, October 13th, 2005

A naivist-approach solution to check if a user belongs to a particular domain group.

Month names. i18n, you know

Monday, September 26th, 2005

Whenever you see something like this you should come to an idea something is wrong (for instance, the guy who wrote this is still alive): ‘month names in Latvian Dim sMonth() As String = _ {”Janvāris”, “Februāris”, “Marts”, “Aprīlis”, _ [...]

Parse the Enum!

Wednesday, September 14th, 2005

What if we need to save the value of an instance of an enumeration (Enum) as string and then get back the value again? For instance, we have the following code: Dim eDay As System.DayOfWeek = DayOfWeek.Monday So now we can get a textual representation of eDay using the built-in ToString() method: MessageBox.Show(eDay.ToString()) This yields a messagebox saying “Monday”. But [...]

String.Concat instead of &

Monday, September 5th, 2005

We all know that the concatenation operator & is evil when you use it intensively. We know writing like this is no good: Dim s as String = “” s &= “<” s &= spFieldName s &= “>” s &= spFieldValue s &= “</” s &= spFieldName s &= “>” This is no good because a new String object is being created for every [...]

Stulbas beigas?

Friday, June 17th, 2005

Par VB.Net String klases metodēm TrimStart() un TrimEnd()

Mainīgo deklarēšana

Tuesday, May 31st, 2005

Starp citu … VB6 skaitījās sliktais stils rakstīt šādi: Dim i, j As Integer Šādas deklarācijas rezultātā i bija ar tipu Variant, bet j bija Integer (nevis kā varētu šķist, abi Integer). Toties VB.net šī pieeja ir tiek atbalstīta un saprasta tieši tā, kā tā izskatās.

MSDN mazliet mānās par ASP.Net failu upload

Friday, May 27th, 2005

Mēģinām augšuplādēt (upload) failu ASP.net lapā. Priekš tam lapas kodā jāievieto apmēram šāds: <input id=”myFile” type=”file” runat=”server” /> <input type=button id=”cmdUp” runat=”server” /> Pēc tam varam ķert notikumu, kad nospiesta upload poga. Pēc MSDN rādītā piemēra, pietiek pārbaudīt vai UploadedFile atribūts nav nothing, tas ir, šādi: Private Sub Uploads (ByVal s As System.Object, ByVal e As [...]

MsExchange piekļuve caur MAPI

Thursday, May 26th, 2005

Pastāstīšu, cik viegli vai grūti ir programmatiski darboties ar MS Exchange objektiem, no koda “lasīt” e-pastu un tamlīdzīgi.