Click here to Skip to main content
15,899,937 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Email sending through vb.net application. Pin
jhoga13-Jun-06 10:14
jhoga13-Jun-06 10:14 
GeneralRe: Email sending through vb.net application. Pin
hbk_leo14-Jun-06 1:53
hbk_leo14-Jun-06 1:53 
GeneralRe: Email sending through vb.net application. Pin
Steven J Jowett14-Jun-06 6:24
Steven J Jowett14-Jun-06 6:24 
QuestionMergeCell in Excell VB.NET Pin
lucdt12-Jun-06 22:26
lucdt12-Jun-06 22:26 
QuestionConverter Pin
Socheat.Net12-Jun-06 22:09
Socheat.Net12-Jun-06 22:09 
QuestionMS Access database and VB Pin
Spiropoulos George12-Jun-06 21:31
Spiropoulos George12-Jun-06 21:31 
Questionhow to write a vb.net code using .ini file Pin
yaseerah12-Jun-06 20:29
yaseerah12-Jun-06 20:29 
AnswerRe: how to write a vb.net code using .ini file Pin
Steven J Jowett14-Jun-06 6:33
Steven J Jowett14-Jun-06 6:33 
Try this class...

Public Class IniFile<br />
    ' API functions<br />
    Private Declare Ansi Function GetPrivateProfileString _<br />
        Lib "kernel32.dll" Alias "GetPrivateProfileStringA" _<br />
        (ByVal lpApplicationName As String, _<br />
        ByVal lpKeyName As String, ByVal lpDefault As String, _<br />
        ByVal lpReturnedString As System.Text.StringBuilder, _<br />
        ByVal nSize As Integer, ByVal lpFileName As String) _<br />
        As Integer<br />
    Private Declare Ansi Function WritePrivateProfileString _<br />
        Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _<br />
        (ByVal lpApplicationName As String, _<br />
        ByVal lpKeyName As String, ByVal lpString As String, _<br />
        ByVal lpFileName As String) As Integer<br />
    Private Declare Ansi Function GetPrivateProfileInt _<br />
        Lib "kernel32.dll" Alias "GetPrivateProfileIntA" _<br />
        (ByVal lpApplicationName As String, _<br />
        ByVal lpKeyName As String, ByVal nDefault As Integer, _<br />
        ByVal lpFileName As String) As Integer<br />
    Private Declare Ansi Function FlushPrivateProfileString _<br />
        Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _<br />
        (ByVal lpApplicationName As Integer, _<br />
        ByVal lpKeyName As Integer, ByVal lpString As Integer, _<br />
        ByVal lpFileName As String) As Integer<br />
<br />
    Dim strFilename As String<br />
<br />
    ' Constructor, accepting a filename<br />
    Public Sub New(ByVal Filename As String)<br />
        strFilename = Filename<br />
    End Sub<br />
<br />
    ' Read-only filename property<br />
    ReadOnly Property FileName() As String<br />
        Get<br />
            Return strFilename<br />
        End Get<br />
    End Property<br />
<br />
    Public Function GetString(ByVal Section As String, _<br />
        ByVal Key As String, ByVal [Default] As String) As String<br />
        ' Returns a string from your INI file<br />
        Dim intCharCount As Integer<br />
        Dim objResult As New System.Text.StringBuilder(256)<br />
        intCharCount = GetPrivateProfileString(Section, Key, _<br />
           [Default], objResult, objResult.Capacity, strFilename)<br />
        If intCharCount > 0 Then GetString = _<br />
           Left(objResult.ToString, intCharCount)<br />
    End Function<br />
<br />
    Public Function GetInteger(ByVal Section As String, _<br />
        ByVal Key As String, ByVal [Default] As Integer) As Integer<br />
        ' Returns an integer from your INI file<br />
        Return GetPrivateProfileInt(Section, Key, _<br />
           [Default], strFilename)<br />
    End Function<br />
<br />
    Public Function GetBoolean(ByVal Section As String, _<br />
        ByVal Key As String, ByVal [Default] As Boolean) As Boolean<br />
        ' Returns a boolean from your INI file<br />
        Return (GetPrivateProfileInt(Section, Key, _<br />
           CInt([Default]), strFilename) = 1)<br />
    End Function<br />
<br />
    Public Sub WriteString(ByVal Section As String, _<br />
        ByVal Key As String, ByVal Value As String)<br />
        ' Writes a string to your INI file<br />
        WritePrivateProfileString(Section, Key, Value, strFilename)<br />
        Flush()<br />
    End Sub<br />
<br />
    Public Sub WriteInteger(ByVal Section As String, _<br />
        ByVal Key As String, ByVal Value As Integer)<br />
        ' Writes an integer to your INI file<br />
        WriteString(Section, Key, CStr(Value))<br />
        Flush()<br />
    End Sub<br />
<br />
    Public Sub WriteBoolean(ByVal Section As String, _<br />
        ByVal Key As String, ByVal Value As Boolean)<br />
        ' Writes a boolean to your INI file<br />
        WriteString(Section, Key, CStr(CInt(Value)))<br />
        Flush()<br />
    End Sub<br />
<br />
    Private Sub Flush()<br />
        ' Stores all the cached changes to your INI file<br />
        FlushPrivateProfileString(0, 0, 0, strFilename)<br />
    End Sub<br />
<br />
End Class


You would then use it like so...

Dim objIniFile As New IniFile("c:\data.ini")<br />
        objIniFile.WriteString("Settings", "ClockTime", "12:59")<br />
        Dim strData As String = _<br />
            objIniFile.GetString("Settings", "ClockTime", "(none)")


Hope this helps

Steve Jowett
Questionprinting form in VB6 Pin
Scorpio12-Jun-06 20:21
Scorpio12-Jun-06 20:21 
QuestionHow to remove null characters in a text file Pin
eddie.jiang.tw12-Jun-06 20:19
eddie.jiang.tw12-Jun-06 20:19 
QuestionMigrating VB 6.0 Data Report to VB.NET Crystal Report. Pin
BAIJUMAX12-Jun-06 19:35
professionalBAIJUMAX12-Jun-06 19:35 
QuestionHow to create stored procedure for executing a package ? Pin
SaravuthYos12-Jun-06 19:16
SaravuthYos12-Jun-06 19:16 
QuestionHow to assign parameter value to Stored procedure from the form in vb.net ? Pin
SaravuthYos12-Jun-06 19:02
SaravuthYos12-Jun-06 19:02 
AnswerRe: How to assign parameter value to Stored procedure from the form in vb.net ? Pin
Steven J Jowett14-Jun-06 6:56
Steven J Jowett14-Jun-06 6:56 
AnswerRe: How to group by hourly,daily,monthly... Pin
Dave Kreskowiak13-Jun-06 2:02
mveDave Kreskowiak13-Jun-06 2:02 
Questionhow do i know detail about textbox's event Pin
roitha12-Jun-06 16:36
roitha12-Jun-06 16:36 
AnswerRe: how do i know detail about textbox's event Pin
Dave Kreskowiak13-Jun-06 1:59
mveDave Kreskowiak13-Jun-06 1:59 
QuestionFunction Replace Pin
angelagke12-Jun-06 16:22
angelagke12-Jun-06 16:22 
AnswerRe: Function Replace Pin
Guffa12-Jun-06 19:20
Guffa12-Jun-06 19:20 
GeneralRe: Function Replace Pin
angelagke12-Jun-06 19:30
angelagke12-Jun-06 19:30 
QuestionHow to read user data from Active Directory? Pin
mypetlily12-Jun-06 16:05
mypetlily12-Jun-06 16:05 
AnswerRe: How to read user data from Active Directory? Pin
bhb1812-Jun-06 20:38
bhb1812-Jun-06 20:38 
QuestionGetting bitmaps off clipboard Pin
MarchJ12-Jun-06 15:58
MarchJ12-Jun-06 15:58 
AnswerRe: Getting bitmaps off clipboard Pin
progload12-Jun-06 21:24
progload12-Jun-06 21:24 
GeneralRe: Getting bitmaps off clipboard Pin
MarchJ22-Jun-06 13:45
MarchJ22-Jun-06 13:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.