Solved

Deighton only !!

Posted on 1998-10-02
7
168 Views
Last Modified: 2010-04-30
so .. i am waiting, your 200 points too :)
0
Comment
Question by:accorp
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1437788
You are a new user and wait for 200 Points?

What's happening
0
 

Author Comment

by:accorp
ID: 1437789
did you see? - Deighton only !!!
0
 
LVL 18

Accepted Solution

by:
deighton earned 200 total points
ID: 1437790
Heres my code with two example click events.

I'll Email you the code too for your convenience.

Private Sub GetContent(sFile As String, _
            sAuthor As String, _
            sEmail As String, _
            sTitle As String, _
            sWords As String, _
            sDescription As String)
         
'This is a subroutine to extract the contents of
'your settings in a file called sFile
         
         Dim sStr1 As String
         Dim sres1 As String
         Dim sYourTag1 As String
         Dim c As Long, iFileNumber As Integer
         
         sYourTag1 = "content"
         iFileNumber = FreeFile
         Open sFile For Input As iFileNumber
         
         'Get the contents info for a particular
         
          While Not EOF(1)
            Line Input #iFileNumber, sStr1
            If InStr(UCase(sStr1), "AUTHOR") Then
               sAuthor = find_text(sStr1, sYourTag1)
            ElseIf InStr(UCase(sStr1), "EMAIL") Then
               sEmail = find_text(sStr1, sYourTag1)
            ElseIf InStr(UCase(sStr1), "TITLE") Then
               sTitle = find_text(sStr1, sYourTag1)
            ElseIf InStr(UCase(sStr1), "WORDS") Then
               sWords = find_text(sStr1, sYourTag1)
            ElseIf InStr(UCase(sStr1), "DESCRIPTION") Then
               sDescription = find_text(sStr1, sYourTag1)
            End If
           
          Wend
             
          Close #1
           

End Sub

Private Function find_text(sString, sTag)

    'Searches a sString for setting sTag
    'e.g. <META name="Author" content="Jim Smith">
    ' find_text(sString,"name") returns Author
   

    Dim i As Integer, iPos As Integer, iStart As Integer

    i = InStr(sString, sTag & "=")
   
    If i <> 0 Then
        iStart = i + Len(sTag) + 1
       
        If Mid(sString, iStart, 1) = """" Then
       
            iPos = iStart + 1
            While Mid(sString, iPos, 1) <> """"
           
                find_text = find_text + Mid(sString, iPos, 1)
                iPos = iPos + 1
       
            Wend
   
        End If
       
    End If


End Function

Private Sub replace_text(sProcess As String, sYourTag As String, sReplace As String)

    'Replace contents for setting in a string

    Dim iPos As Integer
    Dim iLen As Integer
   
    Dim sString As String
   
    iPos = InStr(sProcess, sYourTag & "=")
   
    iPos = iPos + Len(sYourTag) + 1
   
    sString = Left(sProcess, iPos)
   
   
    While Mid(sProcess, iPos + 1 + iLen, 1) <> """"
       
        iLen = iLen + 1
       
    Wend
   
    sProcess = sString & sReplace & Mid(sProcess, iPos + 1 + iLen)
   
End Sub

Private Sub Save_Settings(sFile As String, _
            sAuthor As String, _
            sEmail As String, _
            sTitle As String, _
            sWords As String, _
            sDescription As String)
           
    'Update the file with new settings.
    'the new file is created as a temporary file,
    'then copied over the old one.
           
    Dim iFn1 As Integer
    Dim iFn2 As Integer
    Dim sProcess As String
    Dim sYourTag1 As String
    Dim sTempFile As String
   
    sYourTag1 = "content"
    sTempFile = "c:\temp\1234.txt"
   
    iFn1 = FreeFile
           
    Open sFile For Input As #iFn1
   
    iFn2 = FreeFile
   
    Open sTempFile For Output As #iFn2
           
    While Not EOF(iFn1)
   
        Line Input #iFn1, sProcess
       
        If InStr(UCase(sProcess), "AUTHOR") Then
            Call replace_text(sProcess, sYourTag1, sAuthor)
        ElseIf InStr(UCase(sProcess), "EMAIL") Then
            Call replace_text(sProcess, sYourTag1, sEmail)
        ElseIf InStr(UCase(sProcess), "TITLE") Then
            Call replace_text(sProcess, sYourTag1, sTitle)
        ElseIf InStr(UCase(sProcess), "WORDS") Then
            Call replace_text(sProcess, sYourTag1, sWords)
        ElseIf InStr(UCase(sProcess), "DESCRIPTION") Then
            Call replace_text(sProcess, sYourTag1, sDescription)
        End If
       
        Print #iFn2, sProcess
       
    Wend
   
    Close #iFn1, #iFn2
   
    FileCopy sTempFile, sFile
   
         
End Sub

'Example call

Private Sub Command1_Click()

Dim sFile As String
Dim sAuthor As String
Dim sEmail As String
Dim sTitle As String
Dim sWords As String
Dim sDescription As String


sFile = "a:h.htm"

Call GetContent(sFile, sAuthor, sEmail, sTitle, sWords, sDescription)

text1 = sAuthor
text2 = sEmail
text3 = sTitle
text4 = sWords
text5 = sDescription


End Sub


Private Sub Command2_Click()
   
    Dim sFile As String
    Dim sString As String
    Dim sEmail As String
    Dim sTitle As String
    Dim sWords As String
    Dim sDescription As String
   
   
    sFile = "a:h.htm"
    sString = Text6
    sEmail = Text7
    sTitle = Text8
    sWords = Text9
    sDescription = Text10
   
    Call Save_Settings(sFile, sString, sEmail, sTitle, sWords, sDescription)
   
End Sub










0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:accorp
ID: 1437791
there are some problems
i'll get back with you later

0
 
LVL 9

Expert Comment

by:Dalin
ID: 1437792
accorp,

This seems very fishy...

You did not ask a question.  How does deighton know what you need?  

Why deighton only?  its not like you had a previous question and deighton helped you but did not get any points...




0
 
LVL 18

Expert Comment

by:deighton
ID: 1437793
For reference

This is a link from a previously asked question.

http://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10085232
0
 
LVL 14

Expert Comment

by:waty
ID: 1437794
deighton, did you see that at the link
   
http://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10085232

the user who asked the quection is acorp and the user for this question is accorp?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now