Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Sql Sentence

I have a cost table named TblCost, that show a five fields.
I show all data like SELECT A, B, C, D, E FROM TblCost.
But, i need to show another field result of sum (C+E) fields.
How i can show in a sql sentence the result on a datagrid1 ???


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
If Sentence
In If sentence:

VB Code:
Dim x(0) As Integer If (Not x)        Then Debug.Print "x() is empty" '<<<--- How is this possible???If (Not x) = True Then Debug.Print "x() is empty"
On the other hand:
VB Code:
Dim y As Integer If (y = 0)        Then Debug.Print "y equals 0"If (y = 0) = True Then Debug.Print "y equals 0"
What am i missing? I don't see the difference outside the condition...

SQL Sentence In VB-GOING MAD!!!!
I use the following code and get "Syntax error in update statement". I have tried modifying but to no avail, HELP!!!!

VB Code:
If SetI(Index).Value = 1 Thenacn.Execute ("update settings set " & settings.Fields(Index).Name & " =  " & True & "   ")Elseacn.Execute ("update settings set " & settings.Fields(Index).Name & " =  " & False & "  ")End If

1.SETI is just an index of checkboxes
2.when it erroed, settings.fields(index).name was the name of the field I wanted to change
3.settings is a table of one line containing 5 fields of boolean fields
4.darn this!!!!

Help On This Sentence
can anyone pls tell me what excatly this line is toking about

"allow the user to choose the file-name to initialise a text file for random access"

does this mean that i have to sepecify a name and save it and then open it again for random access??

Sql Sentence
I have this sentence to connect to a Database.

Note: The Database is in BTrieve. I use an ODBC to access the database via ACCESS. When i Run the APP it says: Invalid sentences= SUBSTRING. Of course ACCESS does not accept the SUBSTRING(?) . I tested the Query in ACCESS and change the SUBSTRING to MID$. The QUERY works fine in ACCESS, but when i use in VB it says: MID$ could not be found.

Does anyone have an idea?

sqlstring = "SELECT Docno, Applytodocno, Salespkey, Custkey, Trntyp, Docamt " _
& "From ARTRANH " _
& "WHERE SUBSTRING(Salespkey, 1, 1) <> '0' AND substring(Applytodocno, 1, 1) = 'F' " _
& "ORDER BY Docno"

Set rsPlatinum = New ADODB.Recordset
rsPlatinum.CursorLocation = adUseClient
rsPlatinum.Open sqlstring, cnPlatinum, adOpenForwardOnly, adLockReadOnly

How To Add Sentence To End Of Each Line

this is prob a really easy question but i'm failry new to vb and can't get my head around how to do it. All i want to do is add a sentence to the end of each line in a multiline textbox when a command button is pressed

for example



12206.435 99999
12206.4534 99999
12205.3424 99999
15550.3243 99999

when a command button is pressed. So basically i wanna now how to insert "99999" to the end of every line.


Palindromic Sentence
If anyone remembers I asked a Question a while back about palindromic sentences.
I gave the example of Able was I - I was able, whilst not being technically a palindrome it is the same words.
I was trying to use something other than strReverse to find these sentences.
I was trying the strReverse method but of course this always gave me negative "his is not a palindrome" message.
I finally found a way to do it.
here it is:

Option Explicit

Private Sub cmdQUIT_Click()
'Terminate application
End Sub

Private Sub cmdStart_Click()
'Declare required storage
Dim Sentence As String

'invite user to input word
Sentence = UCase(InputBox("Enter a sentence"))

'Check if word is plalindrome
If IsItAPalindrome(Sentence) Then
picOutput.Print "The sentence is a palindrome"
picOutput.Print "The sentence is not a palindrome"
End If

End Sub

Private Function IsItAPalindrome(ByVal Sentence As String) As Boolean
'Declare required storage

Dim PalPossible As Boolean
Dim FirstWord As String
Dim LastWord As String

PalPossible = True

Do While PalPossible And Len(Sentence) > 1

'Take left part of sentence up to space
'Strip off space
FirstWord = Trim(Left(Sentence, InStr(Sentence, " ")))
'Take right part of sentence up to length of first word
LastWord = Right(Sentence, Len(FirstWord))
'Compare two words
If FirstWord = LastWord Then
'Strip first word and space from sentence
Sentence = Trim(Mid(Sentence, InStr(Sentence, " ")))
'Strip last word and space from sentence
Sentence = Trim(Left(Sentence, Len(Sentence) - Len(LastWord)))
PalPossible = False
End If


IsItAPalindrome = PalPossible

End Function

For once I am not looking for help.

Cheers Steve

BTW is it my connection or is the board slow, I find I cannot read posts sometimes because of timeouts.

Having More Than One Sentence In A Caption
Hey guys, Is there a way you can have more than one caption with only one " ' " mark.
It gets annoying having to type " ' " for every single line.

New Sentence In Form

I am trying to print a series of captions onto a form but i need them to come one ubder the other i.e. each on a new sentence. At the moment they are printing one after the other on the same line.

How do I do this?


Evaluate A Sentence?
how can i evaluate a sentence?
example :

For i = 8 To 11
If (Cells(aktzeile, i) = 0) Then ("CH" & i).Value = False
Next i
in this case CH8, CH9, cH10, CH11 are checkboxes

if you know matlab, the command in matlab is EVAL()


Sql (too Long Sentence)
My sql-strings often be too long and not very surveyable.
How can I split a sql-string to two or more sentence.

Example :
Select field1, field2, field3 From tbl1 Order By field1

Wan't to split the code to be like this :

Select field1,field2, field3
From tbl1
Order by field1

Using ComboBox In SQL Sentence
I used the following SQL sentence to do a search in a database:

"SELECT * FROM Table1 WHERE Column LIKE '" & Text1.Text & "' ORDER BY Column"

What i'm trying to do is to use a ComboBox so i can choose which column to do the search for.
How wolud be the SQL sentence using a ComboBox?

Delete End Of Sentence?
I'm writing a program in Visual Basic, but now I'm quite stuck. The problem I have is that I have written to a textfile from a string, using OUTPUT, but i don't want the whole string, just the beginning. For example, if I enter "Hello world" into a textbox, but don't want the last three letters printed to the file, just "Hello wo", how could I do that? All I want is to delete like the three last characters, whatever I enter in the textbox.


Datetime SQL Sentence
I have the following SP which works ok but not between 00:00 and 23:59:59

CREATE PROCEDURE dbo.GetFechaVencimiento
@CantDiasDesde smallint,
@CantDiasHasta smallint
DECLARE @datDesde datetime
DECLARE @datHasta datetime
SET @datDesde=dateadd(day, @CantDiasDesde, getdate())
SET @datHasta=dateadd(day, @CantDiasHasta,getdate())
SELECT fchr,descr,mbox_env,fvenc FROM mer WHERE fvenc>=@datDesde and fvenc<=@datHasta ORDER BY fvenc

This SP gets the date at the same time, thus not giving me any chance to get one record. This is why I need to conserve the date but not the time.

Hope this is clear to help me to figure this out,


Sentence Case
I have forgotten the name of the function which converts a string to sentence case like ms word. E.G. Capitalise the first letter of the sentence.

Can anyone plz tell me whats the name of the function.

BTW: is this function supported in earlier version of VB, or should i use the one i have written myself. I dont want to use my custom made function because of speed issue.



How To Decode This Sentence?
how to decode(or install with regedit) metrics item which in the theme file?

Selecting The Current Sentence
how do you select the current sentence in a word document using VBA?

Thanks in advance

Word/Sentence Searching
What I am trying to do is split a sentence into words Like

Jocelyne Labylle And Jacob Desvarieux

This would produce 4 words as the and,&,/ Ect are removed

So I end up with:-


If all any words are found in a string it returns all matching records

I Have Tried a query With [Names] Like ""*[String Names]*""" but it seems to only work with each letter???

I have tried a number of other SQL Like In ().

I hope somebody will be able to point me in the right direction

Selecting A Sentence Of Text
Not sure what to use to best accomplish this goal, whether it be a rich text box or if its even possible with VB 6.

I want to be able to add bible verses to whatever is best to use for this.

Many of the verses will need to word wrap.

However the beginning of every verse will have the book /chapter and verse as so (Genesis 1:1).

I would like that section of the verse to be a different color. Each verse will end with several known characters, such as a comma, colon or period.

The main goal I want to achieve is when the mouse is clicked at any portion of the verse, the whole verse can be copied with a subsequent right click of the mouse.

Any help in getting started with this will be appreciated.

How To Get Sentence With Mouse Click
I have RTB with data. I want to reading current sentence when I click on any line/word on textbox.

I am processing data in textbox. When I clicked on any word, my application read that word in variable (with selstart, sellength,seltetxt) and then I processed that data, my problem is that, I must have to process previous sentence as I click on next sentence. How can I get previous sentence.
for example.

This is my name. I live in USA. I am Vbprogrammer.

so when I click anywhere on 2nd sentence(I or Live or in or USA) , my program should return last sentence(This is my name).

Please tell me how can I do that? and my program should not return previous sentence when I click 2nd time on same sentence.

Please help


To Cut A Long Sentence Short
i hve one very small problem...i always try to devide long setences in two lines using _ but it always give error when i do so...for exaple this is the vb code line i want to write......
Open ("C:Documents and SettingsAdministrateurBureaupaulvisual basiclogiciel-vbenvoi" + num + "" + num + ".txt") For Append As #nfile

i tried it like this

'Open ("C:Documents and SettingsAdministrateurBureaupaul_
visual basiclogiciel-vbenvoi" + num + "" + num + ".txt") _
For Append As #nfile

but i could do it as it gave an error...pls tell how to do this...

How Can I Find A Sentence In A Text

I have 10 sentence in a textbox and every sentence or separeted by a -- when I click on a button I can add a new sentence. I would like to know before adding the new sentence if it alerady exist in the textbox

what do I do



First Letter On Each Sentence UCase
i need some help to make text in textbox change to first letter on first word in a sentence UCase.
im a trying to do this: You input Text into a Text Box, you click a radio button, then you click a convert text cmd and it changes the text in the text box to first letter on first word in a sentence UCase.
I have done first letter on each word upper case which was

Option Explicit

Private Sub Command1_Click()
MsgBox makeFirstUCase("hello i aM aaRon")
End Sub

Private Function makeFirstUCase(myStr As String) As String
Dim strArr() As String
Dim i As Integer

strArr = Split(myStr, " ")
For i = 0 To UBound(strArr)
If strArr(i) <> vbNullString Then
strArr(i) = UCase(Left$(strArr(i), 1)) & Right$(strArr(i), Len(strArr(i)) - 1)
End If
makeFirstUCase = makeFirstUCase & strArr(i) & " "

End Function

Please help

Print A Sentence To Txt File
<?xml-stylesheet type="text/xsl" href="xsl_log file.xsl"?>

i want to put above sentence in a 1st line of text file.....
how to write the code?

open "C:aa.txt" for append as #1
print #1,"<sentence put here>"
close #1

HOW To Extract Word From A Sentence?
For example:
if user type "I love icecream"
how do i extract each word and put "I", "love", "icecream" into 3 different variables?
a="I" B="love" C="icecream"

Take A Sentence And Make It Backwards
Isn't there a function that will take text and rewrite it backwards?

For instance, If I type "There's No Place Like Home" in a text box, I would like it to make it say, "emoH ekiL ecalP oN s'erehT".

How hard is that? I think it's instrReverse or something? I've been away from VB for so long I forget these things.


I;d prefer it in C++, but if anyone has it in VB then cool. Thanks!

Finding Names In A Sentence
Can any one suggest me a good logic to find names in a sentence and remove them. For example

Mr.George Wall is the owner of this building. He is John Neil Wall.

I have to find George, Wall, John, Neil. I am using the following code, where I am also using a text file "Names.dic" to store all these names for future use.

VB Code:
Private Function removeNames(sent As String) As String Dim regExp1 As String, regExp2 As String, str As StringDim mainSent As String ' to store the original sentence inputDim pos As Integer, i As IntegerDim deleteNames() As StringmainSent = sent regExp1 = "(?:Mr.|Mrs.|Ms.)[A-Z]+w+"regExp2 = "ws[A-Z]{1}w+" str = TestRegExp_Names(regExp1, mainSent)If str <> "Failed" Then    deleteNames() = Split(str, ",")    For i = LBound(deleteNames) To UBound(deleteNames)        '        'triming of Mr., Mrs. or Ms.        '        If deleteNames(i) <> "" Then            sent = Replace(sent, deleteNames(i), "")            pos = InStr(1, deleteNames(i), ".", 1)            deleteNames(i) = Right(deleteNames(i), Len(deleteNames(i)) - pos)            AddToDictionary (deleteNames(i))        End If    NextEnd If str = TestRegExp_Names(regExp2, mainSent)If str <> "Failed" Then    deleteNames() = Split(str, ",")    For i = LBound(deleteNames) To UBound(deleteNames)        '        'Remove the first character and space included in string        '        If deleteNames(i) <> "" Then            deleteNames(i) = Right(deleteNames(i), Len(deleteNames(i)) - 2)            sent = Replace(deleteNames(i), sent, "")            AddToDictionary (deleteNames(i))        End If    NextEnd IfremovieNames = sentEnd Function Private Function AddToDictionary(name As String)Dim file As String, tName As StringDim fileNum file = "Names.dic"fileNum = FreeFile''Search for the name, print only if name doesnot exist in the file "Names.dic"'Open file For Input As #fileNum    While Not EOF(fileNum)        Line Input #fileNum, tName        If tName = name Then            Close #fileNum            Exit Function        End If    WendClose #fileNumOpen file For Append As #fileNum    Print #fileNum, nameClose #fileNumEnd Function  Function TestRegExp_Names(myPattern As String, myString As String)   'Create objects.   Dim objRegExp As RegExp   Dim objMatch As Match   Dim colMatches   As MatchCollection   Dim RetStr As String    ' Create a regular expression object.   Set objRegExp = New RegExp    'Set the pattern by using the Pattern property.   objRegExp.Pattern = myPattern    ' Set Case Insensitivity.   objRegExp.IgnoreCase = False    'Set global applicability.   objRegExp.Global = True    'Test whether the String can be compared.   If (objRegExp.Test(myString) = True) Then    'Get the matches.    Set colMatches = objRegExp.Execute(myString)   ' Execute search.     For Each objMatch In colMatches   ' Iterate Matches collection.      'RetStr = RetStr & "Match found at position "      'RetStr = RetStr & objMatch.FirstIndex & ". Match Value is '"      RetStr = objMatch.Value & "," & RetStr 'RetStr & objMatch.Value & "'." & vbCrLf    Next       Else    RetStr = Failed   End If     TestRegExp_Names = RetStrEnd Function

SQL Sentence-Update *RESOLVED*
usersDB.Execute ("update declarations set Time_R= ")
what i want to do is take every line and reduce the field called Time_R by 1
one way to do it will be:

VB Code:
Set decP = usersDB.Execute("select * from declarations")While declarations.EOF = FalseusersDB.Execute ("update declarations set Time_R=" & decP("Time_R") - 1 & "  where ID='" & decP("ID") & "' ")declarations.MoveNextWend

now this isn't smart because the update sentece has to go all over the database and update only one line each time. How can i make it update every line without going all over the database many times.

Sentence, Paragraph Counting
Im making a small notepad type thing, and I want to know how to count the following things:

1) Count how many sectences there are in the rich text box
2) Count how many paragraphs there are

Word Sentence Number
hello friends

i am in big trouble. in my project i want to automate the word through OLE.and i want to get the sentence number on which the ibeam mouse pointer is located.
when i run programme, word will automaticaly opened and a document file will be opened.user then selects the line form the document and i want to detect on which sentence the user have clicked.

ok please help

Omit The Section In The Sentence
Does anybody know how to reselect only portion of the string in the sentence.
I have "select * from where col = 1 and col = 2.
I just need the part after where 'col =1 and col = 2'

Can Someone Crack This Encrypted Sentence For Me?

I was hoping someone could crack the following sentence for me. Also, could you give me the code to crack it in VB?




How To Read The SQL Sentence From A Query In VB
Dear VB users,

From a database it is possible read querys with the next code.

Dim DB As Database
Dim N As Integer
Set DB = DBEngine.Workspaces(0)(0)
For N = 0 To DB.QueryDefs.Count - 1
MsgBox DB.QueryDefs(N).Name
Next N

Can someone please tell me how to read the SQL sentences of the querys?

Nice regards,


Unwanted Output At The End Of Sentence
Assume that this is a table with two column-TITLE & DESCRIPTION, in which DESCRIPTION column has been bookmarked. When I retrieve the value of DESCRIPTION column by range object, a strange character appear at the end of the output sentence.

date | 31/12/2004 (bookmark:bm_date)
department | Financial (bookmark:bm_dept)

Below is my VB code:

Dim MSW As Word.Application
Dim doc As Word.Document
Dim date As String
Dim dept As String

Set MSW = New Word.Application
Set doc = MSW.Documents.Open("d:LEAVE APPLICATION FORM.doc", 0, 1)
set date = doc.bookmarks("bm_date").range
set dept = doc.Bookmarks("bm_dept").range

Debug.Print date.Text
Debug.Print dept.Text

The output is:

I = square

how to eliminate the square in the output?

Regex Find Sentence

Does anyone know of a regular expression pattern to find sentences.
I came up with this one based on several web searches. However it only finds one sentence even though i have global set to true.


I am using like so:
CODEMyRegExp.IgnoreCase = True
MyRegExp.Global = True
MyRegExp.Pattern = "[a-zA-Z].*([.!?]s|[.!?])"
Set MyMatches = MyRegExp.Execute(RichTextBox1.SelText)
SentenceCounter = MyMatches.Count

Separate Words From Sentence
I have a problem like this :

I want to get words and the total of the words from a sentence.

Suppose, i have a sentence like this "I am a Happy Man" then i will get
words "I","am","a","Happy","Man". (if the delimiter was " ");
And also i can get how many words are there in my sentence using Ubound.

You might suggest me to just use split function. OK, that will be fine but what about if the sentence goes like this "I am a Happy Man" ? i'll get wrong result.

Maybe someone on this forum can help me with this ?.
This idea came up when i use word count tools on ms Word, but i really don't have a strong background in VB, so i need a help.


Edited by - erc on 11/24/2003 2:44:32 PM

MySql SQL Sentence Clause - NEED HELP S.O.S!!!
I`m writing an app from vb with MySql. I was searching for everywhere in internet about the sql clause. I want to know how to make sql clause from vb whit parameters.


sql_str = "SELECT * FROM table1 where xxx LIKE '*world*'" sql_str, db, , adOpenDynamic, adLockOptimistic

but if you put:

sql_str = "SELECT * FROM table1 where xxx LIKE 'world'" 'whitout the "*" works

"this is an example for you can see what is the problem"


In MS-Access when you put "*" in the critearia query works, but in MySql doesn`t work. All i want to know is, how can i put diferents criteria when there is some part of the STRING.

PD: Forgiveme about my ENGLISH. I speak spanish, i write the best i can

Thank you for your time and knowledge.

Form String Sentence
The variable bitmap are defined as string . How can i make use of line 1 to form the string sentence "save capture 1bitmap.wav " if i is 1?
i = i + 1
bitmap = CStr(i) + "bitmap" 'line 1

Detekt End Off Serial Data Sentence

I tried to build a com to udp aplication, sofar so good.
the serial data is succesfully broadcasted thru the network.

The only problem i have is that the serial dat is not broadcated right.
let me explane

the serial data are nmea sentences witch are different in lenght.
if i set the RThreshold to 1 there is not enough data tranmitted
so i use the trial and error methode and found that RThreshold 170
give's the least problems.

ill bet there is another good way off transmitting the sentenses.

the code i use is this

Private Sub checkActive_Click()

If checkActive.Value = vbChecked Then
MSComm1.CommPort = 1
MSComm1.Settings = "4800,n,8,1"
MSComm1.PortOpen = True
MSComm1.RThreshold = 170


MSComm1.PortOpen = False

End If

End Sub

Private Sub MSComm1_OnComm()
Dim EVMsg$
Dim ERMsg$
Select Case MSComm1.CommEvent
Case comEvReceive
Dim Buffer As String
Buffer = Buffer & MSComm1.Input
Buffer = (StrConv(Buffer, vbUnicode)) + vbCrLf

udppeerA.SendData Buffer
Outputbox.SelText = Buffer
Loop While Len(sData)

the serial data look something like this

this is the output to udp
so you see were it goes wrong line 4

can some one help me ????


Changing Text Color In Mid-sentence
I'm still working on my chat program, and I got it running but have a slight issure that drives me crazy.

I need to find out how I can change the text color in mid-sentence.

For Example:
AOL Instant messenger uses a text color system when sending messages

If bob102 sends a message , it comes onto the screen like
[red]bob102: [normal] message

If somone could let me know how exactly to do this I would be very appreciative. Thanks


Bold A Sentence In Word From VBA Access
I am trying to bold a sentence in Word97 from within Access97. I have the following code........

MyRange.Find.Execute "ZZFirmNameZZ"
MyRange.Words.Last = CheckForNullSTR(rsEmailDetails!fs_firmname)
MyRange.Words.Last.Bold = True
The problem with this is if the field fs_firmname is more than one word it will only bold the first word ? How can i ensure that ALL the words will be bold ?


New Line If # Characters In Sentence Too Long
I want to write a sentence to a file. How would I write the sentence so that it would write to the next line after a certain number of characters without cutting the words up?
Any help would be great!

I know that I could do Left(string, max #characters) then use the Mid function but this would cause the words to be chopped up at the end of the line.

Word In Sentence Replacement Program HELP!
hey guys, i need your help

ok so im trying to make a program that irequests a sentence, a word in the sentence and then a different word. then the program displays the sentence with the first word replaced with the different word

here is what ive come up with so far

Private Sub cmdReplace_Click()
Dim Sentence As String, Word As String, Replacement As String

Sentence = txtSentence.Text

Word = txtWord.Text

Replacement = txtReplace.Text

final = Replace(Sentence, Word, Replacement)

picOutput.Print final

End Sub
i just dont understand how to search for the word in the sentence string

Interactive Text (each Word And Each Sentence)

Is it possible to make each word and/or each sentence of the text in listbox / textbox/richtext be interactive.

I am trying to develop a language learning application in which what I want is that if the user clicks on any word then that click cause an interaction e.g. that word changes its color or displays its meaningin a label.caption or if the user is given an option to select whole sentence in a click and then the whole sentence becomes interactive.

I hope I could clarify what I meant. Feedback will be highly appreciated.



Parse-Sort? Sentence/Paragraph
Don't have much experience with this, but here I go...

I receive a Word file from someone that contains payroll records. I remove the headers, footer, paragraphs, etc., and I'm left with a list of tab delimited records like below.

JohnDoe (tab) 01/01/07 (tab) 12345 (tab) 1451.25

I need to sort each line/paragraph in the list to read like:

12345 (tab) 1451.25 (tab) JohnDoe (tab) 01/01/07

I'm guessing, but I think it would then be easiest to add the new array to a new doc and save. Or maybe just add the sorted record to the same list, then turn around and delete the old records from the list. Not sure.

Using VB6.

Thanks is advance for the help.

Changing A Sentence's Font Color
Alright, this is kind of a stupid question, but I don't know how to do it. I have created a multi-user chat program to use in school, and now I am adding extra features. One of the ones I wanted to do was having a user change his or her font color, but everytime I change the font color on the text box ALL the fonts change color. If anyone could help me out with this just let me know.

Also I have been a member here since May but have never posted, and I want to thank you guys for all the helpful stuff I learn just browsing the website. So THANKS YOU GUYS!

How To Change The Color Of A String In A Sentence??
Hi guys,

I have a "Rich TextBox" on Form1.
I need the following..

If a user types in a specific word (or string if you want) in a sentence THAT word becomes blue. So not the entire text, just that string. Like in Visual Basic itself..



UCase First Character Of Every Sentence In Textbox

can any one help me about converting the first character in uppercase in a sentence


Color Words Inside A Sentence
I have a VB6 form that displays a sentence from a label upon clicking on the command OK.

label1.caption="Good morning Miss Joanna Deneuve...", I want the words Miss Joanna Deneuve to be colored in red and the remaining words in black.

How can I do it?

Copyright 2005-08, All rights reserved