home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / code / various / strngd / form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1994-07-29  |  19.1 KB  |  525 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Sample Application To Demonstrate STRING.DLL Version 1.2b"
  5.    ClientHeight    =   7035
  6.    ClientLeft      =   1245
  7.    ClientTop       =   1710
  8.    ClientWidth     =   8160
  9.    Height          =   7725
  10.    Left            =   1185
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   7035
  13.    ScaleWidth      =   8160
  14.    Top             =   1080
  15.    Width           =   8280
  16.    Begin CommandButton Command8 
  17.       Caption         =   "CountWords"
  18.       Height          =   480
  19.       Left            =   1980
  20.       TabIndex        =   19
  21.       Top             =   3240
  22.       Width           =   1755
  23.    End
  24.    Begin CommandButton Command7 
  25.       Caption         =   "FindFOS"
  26.       Height          =   480
  27.       Left            =   120
  28.       TabIndex        =   18
  29.       Top             =   3240
  30.       Width           =   1755
  31.    End
  32.    Begin CommandButton Command6 
  33.       Caption         =   "FindNOO"
  34.       Height          =   480
  35.       Left            =   120
  36.       TabIndex        =   17
  37.       Top             =   2655
  38.       Width           =   1755
  39.    End
  40.    Begin SSFrame Frame3D1 
  41.       Caption         =   "LexSortStr Demo"
  42.       Font3D          =   3  'Inset w/light shading
  43.       Height          =   2835
  44.       Left            =   105
  45.       TabIndex        =   10
  46.       Top             =   3870
  47.       Width           =   7920
  48.       Begin TextBox textnum 
  49.          Height          =   300
  50.          Left            =   2655
  51.          TabIndex        =   15
  52.          Text            =   "10"
  53.          Top             =   1965
  54.          Width           =   405
  55.       End
  56.       Begin SSCheck casesens 
  57.          Caption         =   "Case sensitive"
  58.          Font3D          =   0  'None
  59.          Height          =   285
  60.          Left            =   2640
  61.          TabIndex        =   14
  62.          Top             =   1560
  63.          Width           =   1935
  64.       End
  65.       Begin CommandButton Command3 
  66.          BackColor       =   &H00000000&
  67.          Caption         =   "Sort the lefthand list into right"
  68.          Height          =   510
  69.          Left            =   2595
  70.          TabIndex        =   13
  71.          Top             =   900
  72.          Width           =   2745
  73.       End
  74.       Begin ListBox List2 
  75.          Height          =   2370
  76.          Left            =   5400
  77.          TabIndex        =   12
  78.          Top             =   315
  79.          Width           =   2445
  80.       End
  81.       Begin ListBox List1 
  82.          Height          =   2370
  83.          Left            =   75
  84.          TabIndex        =   11
  85.          Top             =   315
  86.          Width           =   2445
  87.       End
  88.       Begin Label Label4 
  89.          BackStyle       =   0  'Transparent
  90.          Caption         =   "# of characters to sort by"
  91.          Height          =   240
  92.          Left            =   3105
  93.          TabIndex        =   16
  94.          Top             =   2025
  95.          Width           =   2205
  96.       End
  97.    End
  98.    Begin CommandButton Command5 
  99.       Caption         =   "LexSortStr"
  100.       Height          =   480
  101.       Left            =   120
  102.       TabIndex        =   8
  103.       Top             =   2070
  104.       Width           =   1755
  105.    End
  106.    Begin CommandButton Command4 
  107.       Caption         =   "FindFirstNIS"
  108.       Height          =   480
  109.       Left            =   120
  110.       TabIndex        =   7
  111.       Top             =   1515
  112.       Width           =   1755
  113.    End
  114.    Begin CommandButton Command2 
  115.       Caption         =   "FindRightChar"
  116.       Height          =   480
  117.       Left            =   120
  118.       TabIndex        =   3
  119.       Top             =   960
  120.       Width           =   1755
  121.    End
  122.    Begin TextBox Text2 
  123.       Height          =   975
  124.       Left            =   1965
  125.       MultiLine       =   -1  'True
  126.       ScrollBars      =   3  'Both
  127.       TabIndex        =   2
  128.       Top             =   1815
  129.       Width           =   6090
  130.    End
  131.    Begin TextBox Text1 
  132.       Height          =   1125
  133.       Left            =   1965
  134.       MultiLine       =   -1  'True
  135.       ScrollBars      =   3  'Both
  136.       TabIndex        =   1
  137.       Text            =   "This is a test string; This is a test string; This is a test string; This is a test string; This is a test string; This is a test string; This is a test string; This is a test string; This is a test string; This is a test string; This is a test string; Th"
  138.       Top             =   390
  139.       Width           =   6090
  140.    End
  141.    Begin CommandButton Command1 
  142.       Caption         =   "ReverseStr"
  143.       Height          =   495
  144.       Left            =   120
  145.       TabIndex        =   0
  146.       Top             =   405
  147.       Width           =   1755
  148.    End
  149.    Begin Label Label3 
  150.       AutoSize        =   -1  'True
  151.       BackStyle       =   0  'Transparent
  152.       Caption         =   "
  153. 1994 by INside; P.O. Box 965; 3000 Bern 9; Switzerland"
  154.       Height          =   195
  155.       Left            =   1920
  156.       TabIndex        =   9
  157.       Top             =   6780
  158.       Width           =   4935
  159.    End
  160.    Begin Label Label2 
  161.       AutoSize        =   -1  'True
  162.       BackStyle       =   0  'Transparent
  163.       Caption         =   "Label2"
  164.       FontBold        =   -1  'True
  165.       FontItalic      =   0   'False
  166.       FontName        =   "MS Sans Serif"
  167.       FontSize        =   9.75
  168.       FontStrikethru  =   0   'False
  169.       FontUnderline   =   0   'False
  170.       Height          =   240
  171.       Left            =   4140
  172.       TabIndex        =   6
  173.       Top             =   90
  174.       Width           =   720
  175.    End
  176.    Begin Label Label1 
  177.       AutoSize        =   -1  'True
  178.       BackStyle       =   0  'Transparent
  179.       Caption         =   "Output text window:"
  180.       FontBold        =   -1  'True
  181.       FontItalic      =   0   'False
  182.       FontName        =   "MS Sans Serif"
  183.       FontSize        =   9.75
  184.       FontStrikethru  =   0   'False
  185.       FontUnderline   =   0   'False
  186.       Height          =   240
  187.       Index           =   1
  188.       Left            =   1950
  189.       TabIndex        =   5
  190.       Top             =   1575
  191.       Width           =   1965
  192.    End
  193.    Begin Label Label1 
  194.       AutoSize        =   -1  'True
  195.       BackStyle       =   0  'Transparent
  196.       Caption         =   "Source text window:"
  197.       FontBold        =   -1  'True
  198.       FontItalic      =   0   'False
  199.       FontName        =   "MS Sans Serif"
  200.       FontSize        =   9.75
  201.       FontStrikethru  =   0   'False
  202.       FontUnderline   =   0   'False
  203.       Height          =   240
  204.       Index           =   0
  205.       Left            =   1965
  206.       TabIndex        =   4
  207.       Top             =   90
  208.       Width           =   2040
  209.    End
  210.    Begin Menu dat 
  211.       Caption         =   "&File"
  212.       Begin Menu datei 
  213.          Caption         =   "&Exit"
  214.          Index           =   0
  215.       End
  216.    End
  217.    Begin Menu in 
  218.       Caption         =   "&?"
  219.       Begin Menu info 
  220.          Caption         =   "&Info"
  221.          Index           =   0
  222.       End
  223.    End
  224. Option Explicit
  225. Sub Command1_Click ()
  226. '***********************************************************
  227. '**      SAMPLE CODE FOR THE ReverseStr FUNCTION       **
  228. '***********************************************************
  229. '*   Reverses the indicated string                         *
  230. '***********************************************************
  231. 'variable used to store the return value of the function call:
  232. Dim ret As Integer
  233. 'variables used to time the function call:
  234. Dim tstart As Long
  235. Dim atRev As Long
  236. 'initialize the variables
  237. lpstrDATA = Space$(65000)
  238. 'when calling dll's, the memory for strings being passed
  239. 'back and forth must be allocated by Visual Basic.
  240. 'this is done simply by filling up the variable with blanks!
  241. 'assign the string to be reversed to the variable:
  242. lpstrDATA = text1.Text
  243. 'get the system tick count as a timer mark:
  244. tstart = GetTickCount()
  245. 'execute the dll function:
  246. ret = ReverseStr(lpstrDATA)
  247. 'get the system tick count as a timer mark:
  248. atRev = GetTickCount()
  249. 'assign the resulting string now stored in lpstrDATA to the
  250. 'textfield:
  251. text2.Text = Trim$(lpstrDATA)
  252. 'please note: all the empty space in a string can easily be eliminated
  253. 'by "trimming" the string variable!
  254. MsgBox "It took me " + Trim$(Str$(atRev - tstart)) + " milliseconds to reverse a string 65000 chars length", 64, DLG_CAPTION
  255. If atRev - tstart > 200 Then MsgBox "You must have been reading the about dialog; it normally doesn't take that long! <g> Try it again and it will be *A LOT* faster...", 64, DLG_CAPTION
  256. End Sub
  257. Sub Command2_Click ()
  258. '***********************************************************
  259. '**      SAMPLE CODE FOR THE FindRightChar FUNCTION       **
  260. '***********************************************************
  261. '*   Searches the last occurence of iChar within lpstrDATA *
  262. '*   and highlights the character in the text1 textbox     *
  263. '***********************************************************
  264. 'variable used to store the return value of the function call:
  265. Dim ret As Integer
  266. Dim char As String
  267. char = InputBox("Enter character to be found:")
  268. 'only one character by be searched!
  269. If Len(char) > 1 Then
  270.   MsgBox "only one character by be searched!", 48, DLG_CAPTION
  271.   Exit Sub
  272. End If
  273. iChar = Asc(char)
  274. 'initialize the variables
  275. lpstrDATA = Space$(65000)
  276. 'when calling dll's, the memory for strings being passed
  277. 'back and forth must be allocated by Visual Basic.
  278. 'this is done simply by filling up the variable with blanks!
  279. 'assign the string being searched to the variable:
  280. lpstrDATA = text1.Text
  281. 'execute the dll function:
  282. ret = FindRightChar(lpstrDATA, iChar)
  283. 'the return value stores the position of the last occurence
  284. 'of iChar within lpstrDATA
  285. 'if the return value <= 0 then no occurence
  286. If ret <= 0 Then
  287.   MsgBox "Character not found!", 48, DLG_CAPTION
  288.   text1.SelStart = CLng(ret - 1)
  289.   text1.SelLength = CLng(1)
  290.   text1.SetFocus
  291. End If
  292. End Sub
  293. Sub Command3_Click ()
  294. '***********************************************************
  295. '**      SAMPLE CODE FOR THE LexSortStr FUNCTION       **
  296. '***********************************************************
  297. '* sorts a list containing a bunch of strings *
  298. '***********************************************************
  299. 'variable used to store the return value of the function call:
  300. Dim ret, a, b, position, exited As Integer
  301. Dim iCase As Integer 'Case sensitivity
  302. Dim iNofC As Integer 'Number of Characters to check
  303. Dim lpstrSTRING1 As String * 1024
  304. Dim lpstrSTRING2 As String * 1024
  305. 'initialize the variables
  306. 'allocate memory:
  307. lpstrSTRING1 = Space$(1024)
  308. lpstrSTRING1 = Space$(1024)
  309. 'when calling dll's, the memory for strings being passed
  310. 'back and forth must be allocated by Visual Basic.
  311. 'this is done simply by filling up the variable with blanks!
  312. 'clear the destination listbox:
  313. list2.Clear
  314. '1=case sensitive comparison, 0=non case sensitive
  315. If casesens.Value Then
  316.   iCase = 1
  317.   iCase = 0
  318. End If
  319. 'the number of characters to sort by
  320. iNofC = Val(textnum.Text)
  321. 'add the first entry so we have something to compare with the first string
  322. ' list2.AddItem list1.List(0)
  323. For a = 0 To list1.ListCount - 1
  324.   lpstrSTRING1 = list1.List(a)
  325.   b = -1
  326.     b = b + 1
  327.     lpstrSTRING2 = list2.List(b)
  328.     'execute the dll function:
  329.     ret = LexSortStr(lpstrSTRING1, lpstrSTRING2, iNofC, iCase)
  330.     'the return value shows to following:
  331.     'if ret < 0 : string1 is before string2
  332.     'if ret = 0 : string1 is the same as string2
  333.     'if ret > 0 : string1 is after string2
  334.     If b >= list2.ListCount Then
  335.       list2.AddItem list1.List(a), b
  336.       exited = True
  337.       Exit Do
  338.     End If
  339.   Loop Until ret <= 0
  340.   If exited = False Then
  341.     list2.AddItem list1.List(a), b
  342.   Else
  343.     exited = False
  344.   End If
  345. End Sub
  346. Sub Command4_Click ()
  347. '***********************************************************
  348. '**      SAMPLE CODE FOR THE FindFirstNIS FUNCTION       **
  349. '**      FindFirstNIS = FindFirst[N]ot[I]n[S]ubstring
  350. '***********************************************************
  351. '*   Searches the first occurence of a character in lpstrDATA *
  352. '*   not contained in the subset string lpstrMAP           *
  353. '*   and highlights the character in the text1 textbox     *
  354. '***********************************************************
  355. 'variable used to store the return value of the function call:
  356. Dim ret As Integer
  357. Dim subset As String
  358. Dim lpstrSUBSET As String * 256
  359. 'initialize the variables
  360. 'allocate memory:
  361. lpstrSUBSET = Space$(256)
  362. lpstrDATA = Space$(65000)
  363. 'when calling dll's, the memory for strings being passed
  364. 'back and forth must be allocated by Visual Basic.
  365. 'this is done simply by filling up the variable with blanks!
  366. subset = InputBox("Enter character subset:")
  367. lpstrSUBSET = subset
  368. 'assign the string being searched to the variable:
  369. lpstrDATA = text1.Text
  370. 'execute the dll function:
  371. ret = FindFirstNIS(lpstrDATA, lpstrSUBSET)
  372. 'the return value stores the position of the last occurence
  373. 'of iChar within lpstrDATA
  374. 'if the return value <= 0 then no occurence
  375. If ret <= 0 Then
  376.   MsgBox "Subset not contained within searched DATA!", 48, DLG_CAPTION
  377.   text1.SelStart = CLng(ret)
  378.   text1.SelLength = CLng(1)
  379.   text1.SetFocus
  380. End If
  381. End Sub
  382. Sub Command5_Click ()
  383. '***********************************************************
  384. '**      SAMPLE CODE FOR THE LexSortStr FUNCTION       **
  385. '***********************************************************
  386. '* indicates the lexical order of two strings *
  387. '***********************************************************
  388. 'variable used to store the return value of the function call:
  389. Dim ret As Integer
  390. Dim iCase As Integer 'Case sensitivity
  391. Dim iNofC As Integer 'Number of Characters to check
  392. Dim lpstrSTRING1 As String * 1024
  393. Dim lpstrSTRING2 As String * 1024
  394. 'initialize the variables
  395. 'allocate memory:
  396. lpstrSTRING1 = Space$(1024)
  397. lpstrSTRING1 = Space$(1024)
  398. 'when calling dll's, the memory for strings being passed
  399. 'back and forth must be allocated by Visual Basic.
  400. 'this is done simply by filling up the variable with blanks!
  401. lpstrSTRING1 = InputBox("Enter the first string to compare:")
  402. lpstrSTRING2 = InputBox("Enter the second string to compare:")
  403. iCase = 1 '1=case sensitive comparison, 0=non case sensitive
  404. iNofC = 10 'compare the first 10 characters of the string
  405. 'execute the dll function:
  406. ret = LexSortStr(lpstrSTRING1, lpstrSTRING2, iNofC, iCase)
  407. 'the return value shows to following:
  408. 'if ret < 0 : string1 is before string2
  409. 'if ret = 0 : string1 is the same as string2
  410. 'if ret > 0 : string1 is after string2
  411. Select Case ret
  412. Case Is < 0
  413.   MsgBox "'" + Trim$(lpstrSTRING1) + "' BEFORE '" + Trim$(lpstrSTRING2) + "'", 64, DLG_CAPTION
  414. Case 0
  415.   MsgBox "'" + Trim$(lpstrSTRING1) + "' THE SAME as '" + Trim$(lpstrSTRING2) + "'", 64, DLG_CAPTION
  416. Case Is > 0
  417.   MsgBox "'" + Trim$(lpstrSTRING1) + "' AFTER '" + Trim$(lpstrSTRING2) + "'", 64, DLG_CAPTION
  418. End Select
  419. End Sub
  420. Sub Command6_Click ()
  421. '***********************************************************
  422. '**      SAMPLE CODE FOR THE FindNOO FUNCTION       **
  423. '**      FindNOO = Find[N]umber[O]f[O]ccurences
  424. '***********************************************************
  425. '*   Searches the for the number of occurences of a        *
  426. '*   character in lpstrDATA                                *
  427. '***********************************************************
  428. 'variable used to store the return value of the function call:
  429. Dim ret As Integer
  430. Dim cCHARA As String * 1
  431. 'initialize the variables
  432. 'allocate memory:
  433. lpstrDATA = Space$(65000)
  434. 'when calling dll's, the memory for strings being passed
  435. 'back and forth must be allocated by Visual Basic.
  436. 'this is done simply by filling up the variable with blanks!
  437. cCHARA = InputBox("Enter character to count:")
  438. 'assign the string being searched to the variable:
  439. lpstrDATA = text1.Text
  440. 'execute the dll function:
  441. ret = FindNOO(lpstrDATA, cCHARA)
  442. 'the return value stores the number of occurences
  443. 'if the return value <= 0 then no occurence
  444. MsgBox cCHARA + " was found " + Str$(ret) + " times", 64, DLG_CAPTION
  445. End Sub
  446. Sub Command7_Click ()
  447. '***********************************************************
  448. '**      SAMPLE CODE FOR THE FindFOS FUNCTION       **
  449. '**      FindFOS = Find[F]irst[O]f[S]ubset
  450. '***********************************************************
  451. '*   Searches for the first occurence of any character     *
  452. '*   from lpstrSUBSET in lpstrDATA                         *
  453. '***********************************************************
  454. 'variable used to store the return value of the function call:
  455. Dim ret As Integer
  456. Dim lpstrSUBSET As String * 256
  457. 'because of VB Memory limitations, the subset may
  458. 'only be 256 bytes of size
  459. 'initialize the variables
  460. 'allocate memory:
  461. lpstrDATA = Space$(65000)
  462. lpstrSUBSET = Space$(256)
  463. 'when calling dll's, the memory for strings being passed
  464. 'back and forth must be allocated by Visual Basic.
  465. 'this is done simply by filling up the variable with blanks!
  466. lpstrSUBSET = InputBox("Enter subset to search for:")
  467. 'assign the string being searched to the variable:
  468. lpstrDATA = text1.Text
  469. 'execute the dll function:
  470. ret = FindFOS(lpstrDATA, lpstrSUBSET)
  471. 'the return value stores the position of the first occurence
  472. MsgBox "The first character from '" + Trim$(lpstrSUBSET) + "' was found at position " + Str$(ret), 64, DLG_CAPTION
  473. text1.SelStart = CLng(ret - 1)
  474. text1.SelLength = CLng(1)
  475. text1.SetFocus
  476. End Sub
  477. Sub Command8_Click ()
  478. '***********************************************************
  479. '**      SAMPLE CODE FOR THE CountWords FUNCTION       **
  480. '***********************************************************
  481. '***********************************************************
  482. 'variable used to store the return value of the function call:
  483. Dim ret As Long
  484. 'initialize the variables
  485. 'allocate memory:
  486. lpstrDATA = Space$(65000)
  487. 'when calling dll's, the memory for strings being passed
  488. 'back and forth must be allocated by Visual Basic.
  489. 'this is done simply by filling up the variable with blanks!
  490. 'assign the string being searched to the variable:
  491. lpstrDATA = text1.Text
  492. 'execute the dll function:
  493. ret = CountWords(lpstrDATA)
  494. 'the return value stores the position of the first occurence
  495. MsgBox "The number of words counted is:" + Trim$(Str$(ret)), 64, DLG_CAPTION
  496. End Sub
  497. Sub datei_Click (Index As Integer)
  498. Unload form1
  499. End Sub
  500. Sub Form_Load ()
  501. Dim fhnd As Integer
  502. Dim dummy As String
  503. form1.Left = screen.Width / 2 - form1.Width / 2
  504. form1.Top = screen.Height / 2 - form1.Height / 2
  505. list1.AddItem "this demonstrates"
  506. list1.AddItem "thiS demonstrates"
  507. list1.AddItem "the usE of lexical order"
  508. list1.AddItem "the use of lexical order"
  509. list1.AddItem "string sorting with"
  510. list1.AddItem "string Sorting with"
  511. list1.AddItem "the almighty STRING.DLL"
  512. list1.AddItem "case sensitive"
  513. list1.AddItem "or not; your choice!"
  514. End Sub
  515. Sub info_Click (Index As Integer)
  516. Dim res As Integer
  517. Select Case Index
  518. Case 0
  519.   res = STRINGVer(form1.hWnd)
  520. End Select
  521. End Sub
  522. Sub Text1_Change ()
  523. label2.Caption = "length:" + Str$(Len(text1.Text)) + " characters"
  524. End Sub
  525.