Solved

searching for a quote in VB

Posted on 2010-11-30
7
280 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
Technology Partners: 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

627 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