Solved

searching for a quote in VB

Posted on 2010-11-30
7
278 Views
Last Modified: 2012-05-10
I have a text like the following

ShowMessage("Hello World", "abc")

I try to extract the 'Hello World' text message out in VBA if  I see it is a function ShowMessage.  Of course that can be a space before and after '('.

I have right up a function to examine the function name, then open bracket, and then try to search for the double quote.  What I notice that the Mid(string, 1, 1) function will return me 'H' whether my string is "Hello" or Hello.  
Is there any way I can search for double quote.
Or some other mean to extract the text message.

Thanks.
0
Comment
Question by:tommym121
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34241597
I hope I have understood your query correctly. If not, then please ignore this post and let me know what exactly do you want...

Sub Sample()
    Dim strString As String
    
    strString = """" & "hello" & """"
    
    MsgBox strString
    MsgBox Mid(strString, 1, 1)
End Sub

Open in new window

0
 

Author Comment

by:tommym121
ID: 34241641
The problem, I have import this file with columns of this types of data. What do I do in that situation?
0
 
LVL 39

Expert Comment

by:nutsch
ID: 34241648
something like this?

Thomas
sub get quotes

Dim str As String
str = selection
str = Left(Mid(str, 1 + InStr(str, "(""")), InStr(Mid(str, 1 + InStr(str, "(""")), ""","))
debug.print str

end sub

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Assisted Solution

by:SiddharthRout
SiddharthRout earned 250 total points
ID: 34241669
May I see a sample file?
0
 
LVL 39

Expert Comment

by:nutsch
ID: 34241682
then for your whole selection:
Sub dgasdg()
Dim str As String, cl As range


For Each cl In selection.Cells

    If InStr(cl, "ShowMessage") > 0 Then _
        cl = Left(Mid(cl, 1 + InStr(cl, "(""")), InStr(Mid(cl, 1 + InStr(cl, "(""")), ""","))

Next

End Sub

Open in new window

0
 
LVL 14

Accepted Solution

by:
pteranodon72 earned 250 total points
ID: 34241687
Use InStr to find the position of the first doublequote character in a string. The doublequote character's ASCII code is 39.


Dim intPos as Integer
Dim strSearch as String

intPos = InStr(strSearch, chr(39))

If intPos = 0 Then
  Debug.Print "No double-quotes found in string"
Else
  Debug.Print "File double-quote found at position " & intPos & "."
End If

HTH,
pT72
0
 

Author Closing Comment

by:tommym121
ID: 34247696
Thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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