--7-------------------------------------------------------------
Date sent: Fri, 16 May 1997 13:36:53 -0500 (CDT)
From: Tarik
Suppose I copy a data from the excel to the clipboard, which is as
follows:
Allen 12
Anderson 13
Douglas 12
Ohio 49
How can I read the county name and the data in an array or in a grid box?
the Clipboard.GetText(vbCFText) reads the whole data, i want
to read one
by one.
make a new project, a form, two labels and a commandbutton
Private sub
Command1_Click()
dim
vTekst$
vTekst$ = "Allen 12 "
vTekst$ = vTekst$ & "Anderson 13 "
vTekst$ = vTekst$ & "Bernard 14 "
vTekst$ = vTekst$ & "Constance 15 "
Label1.Caption = vTekst$
select
case
Command1.Caption
case
"Copy Clipboard"
Clipboard.Clear
Clipboard.SetText Label1.Caption
Command1.Caption = "Put into Label"
case
"Put into Label"
Label2.Caption = GetPartofString(Clipboard.GetText, 1)
Command1.Caption = "Copy Clipboard"
'read in array
dim
vText(7) as
String
dim
c%
For c% = 0 To 7
vText(c%) = GetPartofString(Clipboard.GetText, c% + 1)
Next c%
'show result
For c% = 0 To 7
MsgBox vText(c%)
Next c%
End Sub
Private Function GetPartofString(source$, part%) as
String
dim
p%, c%, tmp$
tmp$ = source$
c% = 0
Do
p% = InStr(tmp, Chr(32))
If p% <> 0 Then
GetPartofString = Left(tmp, p% - 1)
c% = c% + 1
tmp = Right(tmp, Len(tmp) - p%)
end
If
Loop While c% <> part%
End Function
--6-------------------------------------------------------------
On 12 May 1997 11:57:58 GMT, "Aviv Shaham" wrote:
>hi
>
>How can I count the charaters in a string
>For example:
>I want
to count the characters in Text1.Text when a use presses OK.
>
How about the command LEN(Text1.text)? You get the lenght..
including spaces and other non-charaters.
So if you want
to loose then too you must use a litte function to check
if a character of text1.text is really a text-charater:
Public Function CountCharacters(source$) as
Integer
dim
counter%, t%
Const Characters$ = "abcdefghijklmnopqrstuvwxyz"
For t% = 1 To Len(source$)
If InStr(Characters, LCase$(Mid$(source$, t%, 1))) <> 0 Then
counter% = counter% + 1
end
If
Next t%
CountCharacters = counter%
End Function
use as
vString$ = "Testing .... about what?"
MsgBox CountCharacters(vString$)
--5-------------------------------------------------------------
On 9 May 1997 02:36:50 GMT, xx007bond@aol.com (XX007BOND) wrote:
>Does anyone know the code needed to make a special kind of loop. I need
>one that as
an example takes the string "Hey how are you" and places each
>letter in a different variable that increases on
its one. Ex. H goes in
>A1. e goes in A2, y goes in A4 and so on. Thanx for your help
Dim vChar() as
String
Sub PlaceInArray(source$)
Dim p%
For p% = 1 To Len(source$)
Redim Preserve vChar(p%)
vChar(p%) = Mid$(source$,p%,1)
Next p%
End Sub
In the array vChar are all
the characters of the given key.
You can use them by calling the right item: ergo Msgbox vChar(1)
--4-------------------------------------------------------------
On Tue, 06 May 1997 10:06:29 -0600, Oyvind Finnesand wrote:
>How do you read words one by one from a text file into string variables?
>Each word in the text file is separated by a single space.
Dim vWords() as
String
Sub SplitStringintoWords(bron$)
Dim c%, p%, t%, vCheck%
Dim TempBron$, tmp$
'splitting the input into words
t% = 0
TempBron$ = bron$
For c% = 1 To Len(bron$)
p% = InStr(TempBron$, Chr(32))
If p% <> 0 Then
ReDim Preserve vWords(t%)
tmp = Left$(TempBron$, p% - 1)
vWords(t%) = StripString(tmp)
TempBron$ = Right$(TempBron$, Len(TempBron$) - p)
t% = t% + 1
c% = c% + p%
end
If
Next c%
ReDim Preserve vWords(t%)
vWords(t%) = StripString(TempBron)
End Sub
First you must read in one line of the textfile and then use the above proc.
In the array vWords are all
the words from the textfiles.
If you need help reading the file let me know
--3-------------------------------------------------------------
On 4 May 1997 21:52:41 GMT, in comp.lang.basic.visual.misc you wrote:
>
>I need to know how to replace the following text with the text next to it
>on all
my text boxes on
a form and at run time. Thanks ahead of time.
>
try this...
BTW it comes form two procedures on
the page below..
'make a new form with a command button and 3 textboxen
'add the code below
'press F5
'and then the command button
Private sub
Command1_Click()
Const vString$ = "testing for somebody on
the net"
select
case
Command1.Caption
case
"&Replace text in all
textboxes"
Text1.Text = vString
Text2.Text = vString
Text3.Text = vString
Command1.Caption = "&Replace somebody with me"
case
"&Replace somebody with me"
Call ChangeText
Command1.Caption = "&Replace text in all
textboxes"
end
Select
End Sub
Function sReplace(SearchLine as
String, SearchFor as
String, _ ReplaceWith as
String)
dim
vSearchLine as
String, found as
Integer
found = InStr(SearchLine, SearchFor): vSearchLine = SearchLine
If found <> 0 Then
vSearchLine = ""
If found > 1 Then vSearchLine = Left(SearchLine, found - 1) _
vSearchLine = vSearchLine + ReplaceWith
If found + Len(SearchFor) - 1 < Len(SearchLine) Then _
vSearchLine = vSearchLine + Right$(SearchLine, _
Len(SearchLine) - found - Len(SearchFor) + 1)
end
If
sReplace = vSearchLine
End Function
Private sub
ChangeText()
dim
Control
For Each Control In Form1.Controls
If TypeOf Control Is TextBox Then
Control.Text = sReplace(Control.Text, "somebody", "me")
end
If
Next Control
End Sub
--2-------------------------------------------------------------
On Tue, 29 Apr 1997 22:19:46 -0300, in comp.lang.basic.visual.misc you wrote:
>I have
a text box so I (as user) can enter a string. I have
a control
>array of 60 little text boxes with words in them for my dictionary. I
>am trying to check each word in my string to see if it matches a word in
>my array. I have
to remove the puncuation before matching the word. If
>the whole sentence is spelled ok I send out a message. If not I send
>out a different message.
>
>Any general advice on
how you would procede with this would be great.
Assuming you have
a textbox where you enter one or more words and you want
to check
it against an array.. you can use the next code as
a starting point..
But consider of making your spellingchecker list a database. When it is growing a
database works much faster.
'on the general section
Dim vWords()
Dim Max%
Dim vCheckWord()
Private Form1_Load()
Text1.SetFocus
Text1.Text = "living in america but not really"
Max% = 10
'make array
'you can use an ascii file to get the words
Redim vCheckWord(Max)
vCheckWord(0) = "walther"
vCheckWord(1) = "musch"
vCheckWord(2) = "america"
vCheckWord(3) = "tilburg"
vCheckWord(4) = "hallo"
vCheckWord(5) = "testen"
vCheckWord(6) = "testing"
vCheckWord(7) = "really"
vCheckWord(8) = "visual"
vCheckWord(9) = "basic"
End Sub
Sub SplitStringintoWords(bron$)
Dim c%, p%, t%, vCheck%
Dim TempBron$, tmp$
Dim vOke as
Boolean
'splitting the input into words
t% = 0
TempBron$ = bron$
For c% = 1 To Len(bron$)
p% = InStr(TempBron$, Chr(32))
If p% <> 0 Then
ReDim Preserve vWords(t%)
tmp = Left$(TempBron$, p% - 1)
vWords(t%) = StripString(tmp)
TempBron$ = Right$(TempBron$, Len(TempBron$) - p)
t% = t% + 1
c% = c% + p%
end
If
Next c%
ReDim Preserve vWords(t%)
vWords(t%) = StripString(TempBron)
'checking against spellingschecker
vOke = False
For c% = 0 To t%
For vCheck% = 0 To Max
If vCheckWord(vCheck%) <> vWords(c%) Then
vOke = False
Else
vOke = True
vCheck% = Max%
end
If
Next vCheck%
If Not vOke Then MsgBox vWords(c%)
vOke = False
Next c%
End Sub
Private sub
Text1_KeyPress(KeyAscii as
Integer)
If KeyAscii = 13 Then
'split string into words
Call SplitStringintoWords(Text1.Text)
end
If
End Sub
Function StripString(source as
String) as
String
Const Letters$ = "abcdefghijklmnopqrstuvwxyz"
Dim p%, tmp$
tmp = source$
For p% = 1 To Len(source$)
If InStr(Letters, LCase(Mid$(source$, p%, 1))) = 0 Then
select
case
p%
case
1
tmp = Right$(source$, Len(source$) - p%)
case
Len(source$)
tmp = Left$(source$, Len(source$) - 1)
case
Else
tmp = Left$(source$, p%) & Right$(source$, Len(source$) - p%)
end
Select
end
If
Next p%
StripString = tmp
End Function
--1-------------------------------------------------------------
On 14 Apr 97 22:13:57 GMT, english@arl.mil (amsaa) wrote:
>Hi,
>
>I need help in determining if a filename has an extension and then stripping it
>off. Basically I want
to get filename and save it as
a backup file with a new
>extension. Is there an easy way to do this without searching for all
"/" in the
>entire path string?
>
start at the back of the path string and search for the first "\"
take the right$; this will give you the filename
If you want
to delete the extension then do the same but search for the first ".".
Beware that a filename in w95 can have
more then one points!
code like this:
Dim p%
Function GetFileName(PathString$) as
String
GetFileName = PathString
For p% = Len(PathString) To 0 Step -1
If Mid$(PathString,p%,1) = "\" then
GetFileName = Right$(PathString,p%)
Exit Function
End If
Next p%
End Function
Return