Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 3rd, 2003, 10:20 PM
mrluce mrluce is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 1 mrluce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Function problem

The function findnth() works fine for my purposes of finding a cell against a specified range and returning a result value if val1 is an exact match. But I need to strip some extra characters out and can't get the function extractroomnumber to work using the following statement (see # below):

If ExtractRoomNumber(Table.Cells(i, SearchCol).Text) = Val1.Text Then ....

Shouldn't this take the text of table.cells, strip off the extra I don't want and evaluate it against the arguement val1? For instance if val1 = "11-386" and table.cells(i.searchcol.text) = "11-386 blah, blah, blah", then I'd want this True.

Help?

Thanks,

Michael

***********************************************
Function FindNth(Table As Range, Val1 As Variant, SearchCol As Integer, Val1Occrnce As Integer, ResultCol As Integer)

Dim i As Integer
Dim iCount As Integer
Dim rCol As Range
Dim tmp As String

For i = 1 To Table.Rows.Count

# If Table.Cells(i, SearchCol).Text = Val1.Text Then
iCount = iCount + 1
End If

If iCount = Val1Occrnce Then
FindNth = Table.Cells(i, ResultCol)
Exit For
End If
Next i

End Function
------------------------------------------------------------------
Function ExtractRoomNumber(roomnumber As String)
Dim startpos As Integer

startpos = InStr(roomnumber, " ")
If startpos > 0 Then
ExtractRoomNumber = Left$(roomnumber, startpos - 1)
Else
ExtractRoomNumber = roomnumber
End If

End Function

Reply With Quote
  #2  
Old November 3rd, 2003, 11:17 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
I have read your code,but i can't find obvious error...U should print the return value of the function ExtractRoomNumber to check it..Or add the type of resturn value:Function ExtractRoomNumber(roomnumber As String)
as string
It's my advice for you..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Function problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway