borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (MSAgent in vb.net)Next Topic (Accessing Excel TextBox from VB.net) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : sos
Poster Message
ppkk
Level: Guest


icon sos

Dear VB Experts,

I have no much idea in visual basic programming, however, I have to do a program which is related to machine translation, would you all please give me a helping hand? Following is the instruction from my professor, I would much appreciate if you could spend precious time in writing the code for me.( as I know, just around twenty rows of codes can make it). You are welcome to send to the following email fd_dfre@yahoo.com.au or reply in this forum directly. With many many many thanks.
Following is the instruction:

Write a VB program to allow user to input sentence “This is a happy-to-gether time” from the window, and then segment the sentence into word sequence with forward minimum(FMM) and backward minimum methods(BMM). Suppose we are given a dictionary with the following words: (There, is, a , happy, to, gather, -, time). Words are stored in the dictionary which could be a text file. (No need to make comparison)

So, I am going to make two button(FMM) and (BMM), with a little window for sentence input, another for output,
If I click the command button (FMM), the result should be “This” “is” “a” “happy-to-gether” “time”
If I click the command button(BMM), the result should be “This” “is” “a” “happy” “to” “gether” “time”.

I don’t know how to write the code, please give me a help!!!Thanks very much
kiki

05-11-2003 at 07:52 AM
| Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: sos

Hi Kiki

Welcome to the forum first of all, I've knocked this up in vb6 but it should be the same in vb.net.

First create a form with

two text boxes called txtInput and txtOutput

two command buttons called cmd FMM and cmd BMM

Then use the code below.

Option Explicit

Private Sub cmdFMM_Click()

    Dim words As Variant
    Dim i As Integer

    ' split the string into variables
    
    words = Split(txtInput.Text, " ")
    
    txtOutput.Text = ""
    
    For i = 0 To UBound(words)
        txtOutput.Text = txtOutput.Text & "“" & words(i) & "” "
    Next i

End Sub

Private Sub cmdBMM_Click()

    Dim words As Variant
    Dim newtext As String
    Dim i As Integer

    newtext = txtInput.Text
    
    ' replace the - with spaces
    
    For i = 1 To Len(newtext)
        If Mid(newtext, i, 1) = "-" Then
            Mid(newtext, i, 1) = " "
        End If
    Next i

    ' split the string into variables

    words = Split(newtext, " ")
    
    txtOutput.Text = ""
    
    For i = 0 To UBound(words)
        txtOutput.Text = txtOutput.Text & "“" & words(i) & "” "
    Next i
    
End Sub



Cheers Steve

“ and ” are the characters you specified as quotes for some reason they did not get copied in here correctly, but replace them with yours  


[Edited by steve_w on 05-11-2003 at 10:36 AM GMT]

05-11-2003 at 10:32 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB.Net : sos
Previous Topic (MSAgent in vb.net)Next Topic (Accessing Excel TextBox from VB.net) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder