PDA

View Full Version : VB tips



GuestX
November 30th, 2002, 18:01
i finished the book for VB. ( it was for kids)
iŽll code a programm to translate Albanian to other
languages but how can i code when the User writes
HelLO , it comes same how Hello or hello ???

P.S SRY 4 MY ENGLISH

Doomulation
November 30th, 2002, 21:58
Be more specific, but as how vb works is that it does not change the case. The text should come out exacly as you write it unless you manipulate it with some functions yourself.

icepir8
December 1st, 2002, 00:32
Originally posted by SculleatR
i finished the book for VB. ( it was for kids)
iŽll code a programm to translate Albanian to other
languages but how can i code when the User writes
HelLO , it comes same how Hello or hello ???

P.S SRY 4 MY ENGLISH

Use the UCASE or LCASE functions.

UCASE("HelLo") returns "HELLO".
LCASE("HelLo") returns "hello"

tbag
December 1st, 2002, 02:22
I thought he ment like on KeyPress ASCII the combinations in ASCII msgbox "Hello!" ^_^

sytaylor
December 1st, 2002, 17:07
Originally posted by SculleatR
i finished the book for VB. ( it was for kids)
iŽll code a programm to translate Albanian to other
languages but how can i code when the User writes
HelLO , it comes same how Hello or hello ???

P.S SRY 4 MY ENGLISH

theres gonna be a lot of word checking, then grammar involved, and to say u dont kno english that well from the sound of ur post are you sure its worth it?

Eagle
December 1st, 2002, 18:48
Translations are a lot more complex than you think, you sure your up for that kind of job? Its not just a matter of taking one word and moving it to another, as sytaylor said, there is grammar and context, and such.

GuestX
December 2nd, 2002, 18:57
i donŽt now how to use LCASE or UCASE but my Code currently:
(Like)


If txt1.Text = "Hello" Or txt1.Text = "hello" Then
txt2.Text = "Hallo"
ElseIf....
(Other Words)...
(and finally if the word was not found)
Else
MsgBox "Word was not found"
End If

Eagle
December 2nd, 2002, 22:49
Originally posted by SculleatR
i donŽt now how to use LCASE or UCASE but my Code currently:
(Like)


If txt1.Text = "Hello" Or txt1.Text = "hello" Then
txt2.Text = "Hallo"
ElseIf....
(Other Words)...
(and finally if the word was not found)
Else
MsgBox "Word was not found"
End If



If ucase(txt1.Text) = "HELLO" Then
txt2.Text = "Hallo"
ElseIf....
(Other Words)...
(and finally if the word was not found)
Else
MsgBox "Word was not found"
End If

Eagle
December 2nd, 2002, 22:55
For multiple words like that you might consider select case statements, they are much faster typing than nested if statements




Select Case ucase(Text1.Text)
Case "HELLO"
Text2.Text = "Hallo"
Case "NEXTWORD"
Text2.Text = "Translation"
Case .....
....

Case Else
MsgBox "Word was not found"
End Select



However this is a very crude way of translating something since you will have thousands of case statements there. You might consider using a ADO database with two fields where one holds the word the other holds the translation. Then all you have to do is search for the word your looking for in the database, and the database can easily be updated too.

sytaylor
December 3rd, 2002, 07:59
Originally posted by Eagle

However this is a very crude way of translating something since you will have thousands of case statements there. You might consider using a ADO database with two fields where one holds the word the other holds the translation. Then all you have to do is search for the word your looking for in the database, and the database can easily be updated too.

very true, ado in VB is extreemly easy and just takes a lil time to get used to... databases can be created in access if your low on resoruces too ;)

GuestX
December 6th, 2002, 20:03
Originally posted by SculleatR
i donŽt now how to use LCASE or UCASE but my Code currently:
(Like)


If txt1.Text = "Hello" Or txt1.Text = "hello" Then
txt2.Text = "Hallo"
ElseIf....
(Other Words)...
(and finally if the word was not found)
Else
MsgBox "Word was not found"
End If



If txt1.Text = "Hello" Or txt1.Text = "hello" Then
txt2.Text = "Hallo"
ElseIf....
(Other Words)...
(and finally if the word was not found)
Else
MsgBox "Word was not found"
End If


fixed, 1a :happy:

GuestX
December 6th, 2002, 20:06
can tll me someone how to use the "TabStrip" or
how to implant a Toolbar ???

Eagle
December 6th, 2002, 20:14
Umm, there is a lot to cover there in the tool bar, any specific question?

As for the tabs, they are pretty easy to use. Just create one and set the number of tabs and set their labels and size and orientation, etc. Use the SSTab (Microsoft Tabbed Dialog Control) the one in the common controls suck. Each Tab has its own index in the Tab property, and each tab has its own caption. Thats really all there is to know about it.

GuestX
December 6th, 2002, 20:16
code ???

Eagle
December 6th, 2002, 20:33
Well it all depends on what you want to do. If you want them to be permanent tabs, there is no code. Tabs are like containers, you place other objects in them, like a frame. If the tabs are permanent its all done in the properties dialog box. If you want the tabs to be dynamic so the names and number of tabs can be changed with code, its pretty self explanitory though. To change focus to a specific tab at runtime

where x is the tab index


SSTab1.Tab = x


after changing the tab you can set the caption just like any other object. The number of tabs can be changed at runtime too.

GuestX
December 7th, 2002, 14:23
my teacher ? :P
Žll experiment a bit...:)

Doomulation
December 8th, 2002, 14:06
Lol, the toolbars are easy to implent.
Just add a reference to "microsoft windows common control 6.0 (sp4)" and you got a toolbar. Add it to the form and click customize in the properties window.

Eagle
December 8th, 2002, 22:14
Originally posted by Doomulation
Lol, the toolbars are easy to implent.
Just add a reference to "microsoft windows common control 6.0 (sp4)" and you got a toolbar. Add it to the form and click customize in the properties window.

Well, the properties are whats complicated, associating them with Image lists can be annoying at times and such, especially if you want to add an image after associating it.

Eagle
December 8th, 2002, 22:15
Originally posted by SculleatR
my teacher ? :P
Žll experiment a bit...:)

Thats really what you have to do sometimes.

Doomulation
December 9th, 2002, 12:13
The images can be a pain in the arse, but otherwise it's rather simple.

Teamz
December 9th, 2002, 13:42
it's not complicated to add images :

Dim btnX As Button

imagelistname.ListImages.Add 1, "name", LoadPicture("image.bmp")

toolbar.ImageList = imagelistname

Set btnX = imagelistname.Buttons.Add(, "name", , tbrDefault, 1)

Eagle
December 9th, 2002, 17:35
Originally posted by Teamz
it's not complicated to add images :

Dim btnX As Button

imagelistname.ListImages.Add 1, "name", LoadPicture("image.bmp")

toolbar.ImageList = imagelistname

Set btnX = imagelistname.Buttons.Add(, "name", , tbrDefault, 1)

1. He wanted to do it at design time.
2. Add an image to that list after setting the list to the toolbar, you will get an error.

GuestX
December 10th, 2002, 13:02
yes iŽve implemented a toolbar without functions :)

GuestX
December 10th, 2002, 13:04
but with PictureBoxŽs or Images or Command button you can
make a toolbar, easier .

GuestX
December 10th, 2002, 15:12
i have found a lot tutorals about dinput & dsound & mp3,
i am trying to code a mp3 player :D
i have watched, its not advanced (or *.wav)
i dont like WinAMP much :D

Eagle
December 10th, 2002, 18:51
Originally posted by SculleatR
but with PictureBoxŽs or Images or Command button you can
make a toolbar, easier .

True, but it doesnt look as good as a tool bar and a tool bar is all done in one method while buttons have several click methods.

Doomulation
December 11th, 2002, 09:07
Originally posted by SculleatR
i have found a lot tutorals about dinput & dsound & mp3,
i am trying to code a mp3 player :D
i have watched, its not advanced (or *.wav)
i dont like WinAMP much :D
Lol, oh so you want? I've done one already, lol.
Can play mp3, wma, midi and wav.

GuestX
December 13th, 2002, 16:30
cool, can you give me some info ???
the tutorials have errors with the


Dim pMC As FilegraphManager

or similar

GuestX
December 13th, 2002, 16:32
and more ... :cry:

Cyberman
December 13th, 2002, 17:52
SculleatR you should probably start a new thread about your MP3 attempts.

I think you are missing a component, you must add the MP3 components to your application, they must be active X.

In reality you are making an MP3 player but not a decoder. Trust me all you are doing is using someones MP3 decoder to generate the audio (lol). MP3 is quite complex. It's actually MPEG 1 Layer 3 audio specification and it became popular because the company that owned the patents (mumble) wasn't collecting royalty fees for it so boom MP3 format became popular because people could make MP3 players and decoders without fear of reprisals. Unfortunately the company who owned the patents changed there minds because it became popular. It still has movement though I guess so I guess MP3 might be here to stay :) You will not see much source code for an MP3 decoder around because of this though. :cry:

Have fun!

Cyb

GuestX
December 13th, 2002, 20:40
there are a lot source codes of MP3, Avi ... players.
I have downloaded some mp3 player sources :)


ps. sry, i havnŽt posted a new thread >_<

Doomulation
December 13th, 2002, 22:23
Technically, all you need to do to play an mp3 file (or wma for that matter), do this :P

Dll declaration:


Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long


Play a file:

mciSendString "play " & strFileToPlay & " from 0", 0&, 0&, 0&

To stop or pause, just switch "play" to "stop" or "pause" and remove " from 0".

...

GuestX
December 14th, 2002, 19:06
Originally posted by Doomulation
Technically, all you need to do to play an mp3 file (or wma for that matter), do this :P

Dll declaration:


Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long


Play a file:

mciSendString "play " & strFileToPlay & " from 0", 0&, 0&, 0&

To stop or pause, just switch "play" to "stop" or "pause" and remove " from 0".

...

THIS THREAD WON`T DIE, TOO :baaa:

GuestX
December 18th, 2002, 11:36
but with a mmcontrol for beginner...
wait im back :P

GuestX
December 18th, 2002, 11:40
well .... planet-source-code.



Sub WAVStop()
Call WAVPlay(" ")
End Sub


Sub WAVLoop(File)
Dim SoundName As String
SoundName$ = File
wFlags% = SND_ASYNC Or SND_LOOP
X = sndPlaySound(SoundName$, wFlags%)
End Sub


Sub WAVPlay(File)
Dim SoundName As String
SoundName$ = File
wFlags% = SND_ASYNC Or SND_NODEFAULT
X = sndPlaySound(SoundName$, wFlags%)
End Sub

there are alot more

GuestX
December 24th, 2002, 23:53
is with DirectSound7 just WAV format playable ???

Doomulation
December 25th, 2002, 18:13
That code above is crap. Trust me.
And DirectSound only supports wave-files, yes.
You'll have to use DirectMusic for midi-files. Mp3 & Wma files are not supported.

GuestX
December 28th, 2002, 11:43
Originally posted by Doomulation
That code above is crap. Trust me.

i know.