Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning only the uppercase letters in string

Status
Not open for further replies.

kalle82

Technical User
Apr 2, 2009
163
SE
Im using VBA with word. Im fetching data via a search made on our internal page. As im not allowed to connect it to the mainframe im stuck with using the source code the searches provides. I have managed parse most of it.

But now I have a problem I can´t seem to solve..

When searching the database the string my parsing returns can have two formats.

First it can consist of a name made up of ONLY uppercase letters, this name have any position.

1. CARL Kristian Thor
2. Sture BERIT Stefan
3. Arne Pelle GÖSTA
4. Bengt PÄR
5. MOHAMMED Achmed

For this case i would like to transform the string into only the name made up of the uppercase letter i.e
1. CARL
2. BERIT
3. GÖSTA
4. PÄR
5. MOHAMMED


Secondly it can return, any given number of namnes but all names consist of uppercase.

1. Carl Kristian Thor
2. Sture berit Stefan
3. Arne Pelle Gösta
4. Bengt Pär
5. Mohammaed Achmed

For this case I want it as it is.

The code used for extracting this is

Dim ie As Object
Set ie = CreateObject("internetexplorer.application")

ie.Visible = False

ie.Navigate " & TextBox3.Value

start = 0
StopTime = 20000000
While start < StopTime
start = start + 1
Wend

numTDs = ie.Document.getElementsByTagName("td").Length
C = ie.Document.body.innerHTML

startnamn = InStr(1, C, "rnamn:") + 28

slutnamn = InStr(1, C, "Mellannamn:") - 37

namnet = Mid(C, startnamn, slutnamn - startnamn + 1)

Here i want a statement to change namnet into one of the two i described above.

Hope this isnt to troubling,

Cheers Carl
 
Hi again!

Didn't have access through the weekend but here's whats inside C.

This is returned when I do a search on my social security numer.

Code:
<table border="0" cellspacing="0">
  <tr>
    <td width="1060" rowspan="2" valign="top"><a
        href="[URL unfurl="true"]http://www.skatte123456.se/"[/URL] target="_blank"><img border="0"
        src="images/skvlogo.gif" width="117" height="23"
        alt="Skatte123456" /></a><img border="0" src="images/blank.gif"
        width="143" height="1" alt="" /></td>
    <td width="80" class="nav"><span class="nlsp"
        name="bakatsp" id="bakatsp">&raquo;</span>
        <a href="personsok.jsp" class="nl"
        name="bakat" id="bakat"
        onfocus="doFocus('bakat');
                 return sSt('Klicka för att gå tillbaka till senaste '
                          + 'sökningen')"
        onblur="doBlur('bakat');
                return sSt('')"
        onmouseover="doMouseOver('bakat');
                     return sSt('Klicka för att gå tillbaka till senaste '
                              + 'sökningen')"
        onmouseout="doMouseOut('bakat');
                    return sSt('')"
        onclick="history.back();
                 return false;">Bak&aring;t</a></td>
    <td width="80" class="nav"><span class="nlsp"
        name="nysoksp" id="nysoksp">&raquo;</span>
        <a href="personsok.do?nySok=true" class="nl"
        name="nysok" id="nysok"
        onfocus="doFocus('nysok');
                 return sSt('Klicka för att göra en ny sökning')"
        onblur="doBlur('nysok');
                return sSt('')"
        onmouseover="doMouseOver('nysok');
                     return sSt('Klicka för att göra en ny sökning')"
        onmouseout="doMouseOut('nysok');
                    return sSt('')">Ny s&ouml;kning</a></td>
    <td width="80" class="nav"><span class="nlsp"
        name="hjalpsp" id="hjalpsp">&raquo;</span>
        <a href="help/HjalpPersonbild.html"
        target="hjalpf" class="nl" name="hjalp" id="hjalp"
        onfocus="doFocus('hjalp');
                 return sSt('Klicka för att visa hjälptexten')"
        onblur="doBlur('hjalp');
                return sSt('')"
        onmouseover="doMouseOver('hjalp');
                     return sSt('Klicka för att visa hjälptexten')"
        onmouseout="doMouseOut('hjalp');
                    return sSt('')"
        onclick="
            return visaHjalp('help/HjalpPersonbild.html')">Hj&auml;lp</a></td>
  </tr>
  <tr>
    <td width="80" height="10"><img border="0" src="images/blank.gif"
        width="80" height="1" alt="" /></td>
    <td width="80" height="10"><img border="0" src="images/blank.gif"
        width="80" height="1" alt="" /></td>
    <td width="80" height="10"><img border="0" src="images/blank.gif"
        width="80" height="1" alt="" /></td>
  </tr>
</table>


<h1>Personbild</h1>


<table border="0" cellspacing="0">
  
  
  
  
  <tr>
    
      <td colspan="2" class="upplys">
        
          Senaste ändring för personen i Navet: 2008-09-22 kl. 21:23:21
        
      </td>
    
  </tr>
  <tr>
    <td width="150" height="10"><img border="0" src="images/blank.gif"
        width="150" height="1" alt="" /></td>
    <td width="1150" height="10"><img border="0" src="images/blank.gif"
        width="350" height="1" alt="" /></td>
  </tr>
  <tr>
    <td class="ledtext">Personnummer/<br />
        Samordningsnummer:</td>
    <td class="data">
      
        820722-2954&nbsp;&nbsp;&nbsp;&nbsp;M
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">F&ouml;rnamn:</td>
    <td class="data">
      
        [b]CARL Kristian Thor[/b]
      
      
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">Mellannamn:</td>
    <td class="data">
      
        &nbsp;
      
      
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">Efternamn:</td>
    <td class="data">
      
        Palsson
      
      
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">Aviseringsnamn:</td>
    <td class="data">
      
        &nbsp;
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">H&auml;nvisningspersonnr:</td>
    <td class="data">
      
        &nbsp;
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td class="ledtext">&nbsp;</td>
    <td class="datavik">
      
        Personen är folkbokförd
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">Datum:</td>
    <td class="data">
      
        2008-09-22
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td class="ledtext">Folkbokf&ouml;ring/<br />senaste folkbokf&ouml;ring</td>
    <td class="ledtext">&nbsp;</td>
  </tr>
  <tr>
    <td class="ledtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;L&auml;n:</td>
    <td class="data">
      
        14&nbsp;&nbsp;&nbsp;&nbsp;Västra Götaland
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Kommun:</td>
    <td class="data">
      
        80&nbsp;&nbsp;&nbsp;&nbsp;Göteborg
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F&ouml;rsamling:</td>
    <td class="data">
      
        10&nbsp;&nbsp;&nbsp;&nbsp;Haga
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fastighet:</td>
    <td class="data">
      
        HAGA 9:6
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td valign="top" class="ledtext">Folkbokf&ouml;ringsadress:</td>
    <td class="data">
      
        
        
          Järntorget 6<br />
        
        
          413 04
        
        
          GÖTEBORG
        
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td valign="top" class="ledtext">S&auml;rskild postadress:</td>
    <td class="data">
      
        &nbsp;
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td valign="top" class="ledtext">Utl&auml;ndsk s&auml;rskild
        postadress eller adress f&ouml;r utvandrad:</td>
    <td valign="top" class="data">
      
        &nbsp;
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td class="ledtext">Civilst&aring;nd:</td>
    <td class="data">
      
        Ogift
      
    </td>
  </tr>
</table>


<table border="0" cellspacing="0">
  <tr>
    <td width="100" height="20"><img border="0" src="images/blank.gif"
        width="100" height="1" alt="" /></td>
    <td width="770" height="20"><img border="0" src="images/blank.gif"
        width="85" height="1" alt="" /></td>
    <td width="180" height="20"><img border="0" src="images/blank.gif"
        width="65" height="1" alt="" /></td>
    <td width="105" height="20"><img border="0" src="images/blank.gif"
        width="105" height="1" alt="" /></td>
    <td width="105" height="20"><img border="0" src="images/blank.gif"
        width="105" height="1" alt="" /></td>
    <td width="40" height="20"><img border="0" src="images/blank.gif"
        width="40" height="1" alt="" /></td>
  </tr>
  <tr>
    <td colspan="6" class="upplys">Relationer</td>
  </tr>
  
  
    
    <tr>
      <td height="10" colspan="5"></td>
    </tr>
    <tr>
      <td valign="top" class="ledtext">Personnummer</td>
      <td valign="top" class="ledtext">Namn</td>
      <td valign="top" class="ledtext">Relationstyp</td>
      <td valign="top" class="ledtext">V&aring;rdnad from</td>
      <td valign="top" class="ledtext">Avliden</td>
    </tr>
    <tr>
      <td height="10" colspan="5"></td>
    </tr>
  
  
    
    
    
      
      <tr>
        <td valign="top" class="data">
          
          
            
              <a href="personsok.do?idPersSelect=480922-5941"
                  onmouseover="return sSt('Klicka för att gå till personbilden')"
                  onmouseout="return sSt('')">
                480922-5941
              </a>
            
          
        </td>
        
        <td valign="top" class="data">
          
          
            Bennerfelt Palsson, Inger Kristina
          
        </td>
        <td valign="top" class="data">
          
            Moder
          
        </td>
        <td valign="top" class="data">
          
            &nbsp;
          
        </td>
        <td valign="top" class="data">
          
            &nbsp;
          
        </td>
      </tr>
      
    
    
  
    
      <tr>
        <td height="5" colspan="5"></td>
      </tr>
    
    
    
      
      <tr>
        <td valign="top" class="data">
          
          
            
              <a href="personsok.do?idPersSelect=521209-2331"
                  onmouseover="return sSt('Klicka för att gå till personbilden')"
                  onmouseout="return sSt('')">
                521209-2331
              </a>
            
          
        </td>
        
        <td valign="top" class="data">
          
          
            Palsson, Gudbjörn Thor
          
        </td>
        <td valign="top" class="data">
          
            Fader
          
        </td>
        <td valign="top" class="data">
          
            &nbsp;
          
        </td>
        <td valign="top" class="data">
          
            &nbsp;
          
        </td>
      </tr>
      
    
    
  
  
  
  
</table>


</body>

This is the string I got problems with this is returned when I type in Patricia's SSN.

Code:
<body bgcolor="#ffffcc">


<table border="0" cellspacing="0">
  <tr>
    <td width="1060" rowspan="2" valign="top"><a
        href="[URL unfurl="true"]http://www.skatte123456.se/"[/URL] target="_blank"><img border="0"
        src="images/skvlogo.gif" width="117" height="23"
        alt="Skatte123456" /></a><img border="0" src="images/blank.gif"
        width="143" height="1" alt="" /></td>
    <td width="80" class="nav"><span class="nlsp"
        name="bakatsp" id="bakatsp">&raquo;</span>
        <a href="personsok.jsp" class="nl"
        name="bakat" id="bakat"
        onfocus="doFocus('bakat');
                 return sSt('Klicka för att gå tillbaka till senaste '
                          + 'sökningen')"
        onblur="doBlur('bakat');
                return sSt('')"
        onmouseover="doMouseOver('bakat');
                     return sSt('Klicka för att gå tillbaka till senaste '
                              + 'sökningen')"
        onmouseout="doMouseOut('bakat');
                    return sSt('')"
        onclick="history.back();
                 return false;">Bak&aring;t</a></td>
    <td width="80" class="nav"><span class="nlsp"
        name="nysoksp" id="nysoksp">&raquo;</span>
        <a href="personsok.do?nySok=true" class="nl"
        name="nysok" id="nysok"
        onfocus="doFocus('nysok');
                 return sSt('Klicka för att göra en ny sökning')"
        onblur="doBlur('nysok');
                return sSt('')"
        onmouseover="doMouseOver('nysok');
                     return sSt('Klicka för att göra en ny sökning')"
        onmouseout="doMouseOut('nysok');
                    return sSt('')">Ny s&ouml;kning</a></td>
    <td width="80" class="nav"><span class="nlsp"
        name="hjalpsp" id="hjalpsp">&raquo;</span>
        <a href="help/HjalpPersonbild.html"
        target="hjalpf" class="nl" name="hjalp" id="hjalp"
        onfocus="doFocus('hjalp');
                 return sSt('Klicka för att visa hjälptexten')"
        onblur="doBlur('hjalp');
                return sSt('')"
        onmouseover="doMouseOver('hjalp');
                     return sSt('Klicka för att visa hjälptexten')"
        onmouseout="doMouseOut('hjalp');
                    return sSt('')"
        onclick="
            return visaHjalp('help/HjalpPersonbild.html')">Hj&auml;lp</a></td>
  </tr>
  <tr>
    <td width="80" height="10"><img border="0" src="images/blank.gif"
        width="80" height="1" alt="" /></td>
    <td width="80" height="10"><img border="0" src="images/blank.gif"
        width="80" height="1" alt="" /></td>
    <td width="80" height="10"><img border="0" src="images/blank.gif"
        width="80" height="1" alt="" /></td>
  </tr>
</table>


<h1>Personbild</h1>


<table border="0" cellspacing="0">
  
  
  
  
  <tr>
    
      <td colspan="2" class="upplys">
        
          Senaste ändring för personen i Navet: 2008-06-11 kl. 23:55:53
        
      </td>
    
  </tr>
  <tr>
    <td width="150" height="10"><img border="0" src="images/blank.gif"
        width="150" height="1" alt="" /></td>
    <td width="1150" height="10"><img border="0" src="images/blank.gif"
        width="350" height="1" alt="" /></td>
  </tr>
  <tr>
    <td class="ledtext">Personnummer/<br />
        Samordningsnummer:</td>
    <td class="data">
      
        771231-0429&nbsp;&nbsp;&nbsp;&nbsp;K
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">F&ouml;rnamn:</td>
    <td class="data">
      
        Patricia
      
      
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">Mellannamn:</td>
    <td class="data">
      
        &nbsp;
      
      
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">Efternamn:</td>
    <td class="data">
      
        Johannesson
      
      
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">Aviseringsnamn:</td>
    <td class="data">
      
        &nbsp;
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">H&auml;nvisningspersonnr:</td>
    <td class="data">
      
        &nbsp;
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td class="ledtext">&nbsp;</td>
    <td class="datavik">
      
        Personen är folkbokförd
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">Datum:</td>
    <td class="data">
      
        2008-05-31
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td class="ledtext">Folkbokf&ouml;ring/<br />senaste folkbokf&ouml;ring</td>
    <td class="ledtext">&nbsp;</td>
  </tr>
  <tr>
    <td class="ledtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;L&auml;n:</td>
    <td class="data">
      
        14&nbsp;&nbsp;&nbsp;&nbsp;Västra Götaland
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Kommun:</td>
    <td class="data">
      
        80&nbsp;&nbsp;&nbsp;&nbsp;Göteborg
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F&ouml;rsamling:</td>
    <td class="data">
      
        10&nbsp;&nbsp;&nbsp;&nbsp;Haga
      
    </td>
  </tr>
  <tr>
    <td class="ledtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fastighet:</td>
    <td class="data">
      
        HAGA 9:6
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td valign="top" class="ledtext">Folkbokf&ouml;ringsadress:</td>
    <td class="data">
      
        
        
          Järntorget 6<br />
        
        
          413 04
        
        
          GÖTEBORG
        
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td valign="top" class="ledtext">S&auml;rskild postadress:</td>
    <td class="data">
      
        &nbsp;
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td valign="top" class="ledtext">Utl&auml;ndsk s&auml;rskild
        postadress eller adress f&ouml;r utvandrad:</td>
    <td valign="top" class="data">
      
        &nbsp;
      
    </td>
  </tr>
  <tr>
    <td height="10" colspan="2"></td>
  </tr>
  <tr>
    <td class="ledtext">Civilst&aring;nd:</td>
    <td class="data">
      
        Skild&nbsp;&nbsp;&nbsp;&nbsp;2007-06-15
      
    </td>
  </tr>
</table>


<table border="0" cellspacing="0">
  <tr>
    <td width="100" height="20"><img border="0" src="images/blank.gif"
        width="100" height="1" alt="" /></td>
    <td width="770" height="20"><img border="0" src="images/blank.gif"
        width="85" height="1" alt="" /></td>
    <td width="180" height="20"><img border="0" src="images/blank.gif"
        width="65" height="1" alt="" /></td>
    <td width="105" height="20"><img border="0" src="images/blank.gif"
        width="105" height="1" alt="" /></td>
    <td width="105" height="20"><img border="0" src="images/blank.gif"
        width="105" height="1" alt="" /></td>
    <td width="40" height="20"><img border="0" src="images/blank.gif"
        width="40" height="1" alt="" /></td>
  </tr>
  <tr>
    <td colspan="6" class="upplys">Relationer</td>
  </tr>
  
  
    
    <tr>
      <td height="10" colspan="5"></td>
    </tr>
    <tr>
      <td valign="top" class="ledtext">Personnummer</td>
      <td valign="top" class="ledtext">Namn</td>
      <td valign="top" class="ledtext">Relationstyp</td>
      <td valign="top" class="ledtext">V&aring;rdnad from</td>
      <td valign="top" class="ledtext">Avliden</td>
    </tr>
    <tr>
      <td height="10" colspan="5"></td>
    </tr>
  
  
    
    
    
      
      <tr>
        <td valign="top" class="data">
          
          
            
              <a href="personsok.do?idPersSelect=520328-2073"
                  onmouseover="return sSt('Klicka för att gå till personbilden')"
                  onmouseout="return sSt('')">
                520328-2073
              </a>
            
          
        </td>
        
        <td valign="top" class="data">
          
          
            Rodziewicz, Stanislaw
          
        </td>
        <td valign="top" class="data">
          
            Fader
          
        </td>
        <td valign="top" class="data">
          
            &nbsp;
          
        </td>
        <td valign="top" class="data">
          
            &nbsp;
          
        </td>
      </tr>
      
    
    
  
    
      <tr>
        <td height="5" colspan="5"></td>
      </tr>
    
    
    
      
      <tr>
        <td valign="top" class="data">
          
          
            
              <a href="personsok.do?idPersSelect=550305-2606"
                  onmouseover="return sSt('Klicka för att gå till personbilden')"
                  onmouseout="return sSt('')">
                550305-2606
              </a>
            
          
        </td>
        
        <td valign="top" class="data">
          
          
            Mazurek, Barbara
          
        </td>
        <td valign="top" class="data">
          
            Moder
          
        </td>
        <td valign="top" class="data">
          
            &nbsp;
          
        </td>
        <td valign="top" class="data">
          
            &nbsp;
          
        </td>
      </tr>
      
    
    
  
  
  
    
    <tr>
      <td height="10" colspan="5"></td>
    </tr>
    <tr>
      <td valign="top" class="ledtext">&nbsp;</td>
      <td valign="top" class="ledtext">&nbsp;</td>
      <td valign="top" class="ledtext">&nbsp;</td>
      <td valign="top" class="ledtext">Relationsdatum</td>
      <td valign="top" class="ledtext">Avliden</td>
      <td valign="top" class="ledtext">&nbsp;</td>
    </tr>
    <tr>
      <td height="10" colspan="5"></td>
    </tr>
  
  
    
    
    
      
      <tr>
        <td valign="top" class="data">
          
          
            
              <a href="personsok.do?idPersSelect=770712-3977"
                  onmouseover="return sSt('Klicka för att gå till personbilden')"
                  onmouseout="return sSt('')">
                770712-3977
              </a>
            
          
        </td>
        
        <td valign="top" class="data">
          
          
            Johannesson, Johan Christian
          
        </td>
        <td valign="top" class="data">
          
            Make/Maka
          
        </td>
        <td valign="top" class="data">
          
            
              
                Skild:
              
            
            
            <nobr>
              2007-06-15
            </nobr>
          
        </td>
        <td valign="top" class="data">
          
            &nbsp;
          
        </td>
      </tr>
      
      
    
    
  
</table>

</body>
 
Well so far we have gone through strings that look like,

"CARL Kristian Thor"

and

"Patricia Märta Louise"

but sometimes there are strings that only contain

"Patricia"

Ive been thinking all this weekend, can the split function cause the data returned to be "nothing"?!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top