Solved

Deighton only !!

Posted on 1998-10-02
7
167 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

757 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

22 Experts available now in Live!

Get 1:1 Help Now