kain_mcbride 12 Light Poster

Anybody help me please,
how can i run bat file code in vb6.
can i run it.
thanks,for read

bat, as in .bat file code? you could use the shell function. been a while since i've used it but i'm pretty sure it's
Shell "path\file", [windowstyle]
i suppose in theory you could run a series of them like...

shell "cd %programfiles%", vbHide       'Not that the vbHide / etc part
shell "md newProgDir", vbNormalFocus    'is all that important, but yeah...
shell "cd newProgDir", vbNormalNoFocus  
shell "explorer %cd%", vbMinimizedFocus

or somethin like that... hopefully that helps you out some :) been a very long time since i've looked at this stuff though.

do it in brackets

lSomeWindowID = Shell("notepad", vbNormalFocus")

would put the process id of the new instance of notepad into iSomeWindowID... anyway, again it's been a very long time so my memory might be off... hope it helps :)

kain_mcbride 12 Light Poster

Please help me how to ignore case sensitivity in VB. My program is to store data in the database, though I use small letters or big letters, the database store the data starting with a capital letter followed by small letters. Ex.

Input: Neil, neil, NEIL

In the database: Neil

So if I input Neil, the program response is ok but if I input neil or NEIL, the program results an error in the database and the program exits.

Please I need your kind help. Thank you so much.

Regards,
Neil

hi

try formatting the data before actually submitting it to the database initially... its been a fairly long time since i've done that much with formatting text in visual basic, so i'm not really sure if there's a default way to force name style capitalization of words, but either way... you could do it like this...

Private Function PropperName(stDATA As String) as String
 'holds returned word array, just incase ya know?
 Dim stWords() As String
 'just a loop variable
 Dim iLoop As Integer
 
 'split the submitted data into individual words, after setting
 'all characters to lower case
 stWords = getWords(LCase(stDATA))
 'loop the words, set them the first character to upper case
 For iLoop = LBound(stWords) To UBound(stWords)
  Mid$(stWords(iLoop), 1, 1) = UCase$(Left$(stWords(iLoop), 1))
 Next iLoop
 
 PropperName = Join(stWords, " ")
End Function

Private Function getWords(stDATA) As String()
 getWords = Split(stDATA, " ", , vbTextCompare)
End Function

keeping in mind that the getwords isn't really needed, but …

kain_mcbride 12 Light Poster
private sub doLoopedStuff()
 do while(bRunning=true)
  'your code stuff
  doEvents
 loop
end sub

You know, after doing doEvents , our program should Exit Do .

Thank a lot.
zawpai

hello zawpai

I don't fully understand, and may have misunderstood your initial problem. You were having problems with the MouseDown event, which you were trying to use to cause your program to run continually until the button was released. I assumed that you meant that you had a section of code that you wanted to run repeatedly while the button was held down.

As such, i put it in a do while loop, with the clause that bRunning had to be true for the loop to continue... DoEvents prevents the program from taking full priority in the loop, causing the events that should be firing to fire vs waiting in the loop for whatever clause or justification that needs to be met to be met...

Anyway, i'm not really sure what you mean now. :(

kain_mcbride 12 Light Poster

Can I ask you one more question? What the difference between MouseDown and Click ?

MouseDown is when you push the mouse button down... it's not a full click, just when you press the button... Click is a full click... mouse down / mouse up in close succession over the same object / location...

typicly click would be used... just detects if the user has clicked something in a normal kind of way... however, i understood your specifications to say that the program would run continually until the button was released... so, mouse down fires where as click won't... then you can use mouse up later to break the loop :)

kain_mcbride 12 Light Poster

Unfortunately, alt isn't a standard key... so you're pretty much going to have to use the key up and key down events if you want full detection of what they're doing...

is key down - alt is keycode 18 shift 4, key up - just keycode 18 since it's no longer pressed...

numbers on the numeric keypad are listed as 96 through 105 (0 through 9) as opposed to 48 through 57 at the top of the keyboard.

you could do it this way, but it could probably be written better... (4:50 am, im tired)

also though i don't see why you wouldn't just let the user type stuff in with the alt keys / numeric keypad on their own? i'd think it would double type if you both convert their input and make them type it in..? ie: alt 097 would produce 'a' normally, but coding control for it as well would produce 'aa', no?

option explicit
private bALT_Down as boolean
private lKeyCode as long

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
 if keycode = 18 and shift = 4 then 
  bALT_Down = true
 else
  if bALT_Down = true then getKey(KeyCode)
 end if
end sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
 if keycode = 18 then bALT_Down = false
 call GetKeyCode
end sub

private sub getKey(keyCode as long)
 if keycode >= 96 and keycode <= 105 then
  lKeyCode = lKeyCode * 10
  lKeyCode = lKeyCode + keyCode - 96
 end if …
kain_mcbride 12 Light Poster

hi, i posted about this a while back... should help you out some...

http://www.daniweb.com/forums/thread158280.html

kain_mcbride 12 Light Poster

when you say running the application continuously, i'm assuming you mean there's looping going on?

alright... well, there are a few ways you could do it... easiest way might be defining a boolean variable... for instance

option explicit
private bRunning as boolean

then you can set the variable and run whatever you're running with the mouse down event...

Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
 'set the variable
 bRunning = true
 'run the program
 call doLoopedStuff
end sub

then with the mouse up event you terminate it

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
 bRunning = false
end sub

all this is nice and all, but won't really help much if your program is looping intencely and doesnt' pay attention to the events... so be sure to DoEvents

private sub doLoopedStuff()
 do while(bRunning=true)
  doEvents
  'your code stuff
 loop
end sub
Comatose commented: Absolutely Well Done. +8
kain_mcbride 12 Light Poster

hi,

well, you can't call DataArrival; its an event that fires when you recieve data through that winsock control... you can use it to tell your program what to do with set data, but as far as i know, you can't call it directly (without error handling and expecting to get an error)...

kain_mcbride 12 Light Poster

well, unfortunately i don't remember how to convert an enum to its string value... not sure i ever knew actually ;). anyway; the enum set up for this is

MSWinsockLib.StateConstants

others you might be interested in are

MSWinsockLib.ErrorConstants
MSWinsockLib.ProtocolConstants

having your program automaticly list the status changes could be done by looping; but that takes up a fair bit of processor time... and basicly locks your program up; though if you had a connection loop, which i believe you do; you could update the status in the text box everytime you finished a loop... keep track of what your previous status was and only add the new status if it changes... to add it to a text box, on the next line, just set the text box to multiline and add the new status with vbCrlf (character return, line feed) to break the line... might also want to lock the text box so the user can't alter it's current contents...

you could also use a direct loop that just monitored the state for changes; this would basicly lock up the program until it decides it's finished with the conection attempt... you could break the loop upon achiving the status you want, an error, or a timeout...

hope that helps some, might just be confusing... not enough coffee yet for 3 am...

squidd commented: very good +2
kain_mcbride 12 Light Poster

ambiguous name detected because you have to lead the variable name with a b (naming convention for boolean), otherwise you're matching the sub name completely which works as an abiguity...

as for the piece related to state; it was a different method to solve the problem... if you attempt to connect with winsock (control), the state changes during the connection attempt; if the connection attempt errors, the state will be set to 9... if you're trying to make it log in, you could loop while the state is not 7 or 9, if it's 7 then the connection has been successfully established, if it's 9, then it errored... you could also use it in combinatoin with something similar to your pause proceedure you'd listed before to set a time out of, say... 10 seconds....

anyway... :) just a thought...

kain_mcbride 12 Light Poster

... i really need to drink more coffee at night...

ok, since you're using the winsock control, you have a few options you can use... in this case, the name of your control is Winsock2 i think... anyway...

winsock2.state, check that out...

.state can be several things, 0 through to 9

0 - closed
1 - open
2 - listening
3 - connection pending
4 - resolving host
5 - host resolved
6 - connecting
7 - connected
8 - closing
9 - error

so, check it and see where you're at...

kain_mcbride 12 Light Poster

well, one way to tell what subs were successful and which ones weren't would be to create a set of boolean flags... for example...

private bSomeSub as boolean
private bSomeFunction as boolean

private sub SomeSub()
 on error goto Oops
 'whatever is in the sub
 'lots of code or not so much :p
 bSomeSub = true
Oops:
end sub

private function SomeFunction() as byte
 on error goto Oops
 'whatever the function code is
 'lots of code :p
 SomeFunction = resultingData
 bSomeFunction = true
Oops:
end Function

then when you retest you run the sub you can check what still needs to run...

private sub cmdCommand_Click()
 if bSomeSub = false then call SomeSub
 if bSomeFunction = false then someResult = SomeFunction(someData)
end sub
kain_mcbride 12 Light Poster

was just wondering about the check for reset... instr will check within String1 for an instance of String2, string2 being reset, if String1 is set to anything including reset, it'll come back as true...

so reset will come back as saying, yes... it says reset...
preset will come back as saying that it says reset...
and 324resetas351 will come back as saying that it says reset...

might want to use

if pass <> "reset" then
 'your valid password code
elseif pass = "reset" then
 'your reset password code
end if

better yet, might want to use a string of charaters they can't use as a password... for instance
stReset = chr$(13) & chr$(13) & chr$(13)

squidd commented: thank you +2
kain_mcbride 12 Light Poster

looking at that, wouldn't think so...

alright, unrelated to the form not disapearing... i have a question about your code...

what happens if someone uses presetpass as their password? (or some random combination of alphanumeric characters that happens to contain the string reset in the somewhere inside of it..?

as a note... with the code provided; i can see no reason that the form would keep coming back...

kain_mcbride 12 Light Poster

I'm assuming that the program is being told to wait 1.5 seconds before continuing. Is 'pause' not a valid command?

It makes sense 'logically'...but if it's not a command - it's not a command. :P

not a command as far as i know, there use to be a sleep command in qbasic (i think)... but writing a pause sub is doable to say the least... assuming one was written for use with this program, how its set up could be part of the problem i guess...

funny, i've never used form.visible = true / false to show or hide forms... always just used .show or .hide... didn't even know it worked until now... well there's my new thing for the day ;)

[edit]ok... so i probably shouldn't be posting at 6:30 am with no sleep... sorry, didn't notice the second page :$ [/edit]

kain_mcbride 12 Light Poster

well; depending on where this image is... if it's within your project - as opposed to an external file - you could print it from whatever image control it's in... if it is an external file you could load it into an image type control (image box, picture box, anything that has a .picture attached to it...) or, you might be able to just load the picture directly onto the printbuffer mentioned below (i didn't try it though)

using the printer object in vb6 will let you print this to a print buffer. with Printer.PaintPicture (you can look up the syntax) you can add your picture do the print buffer, when you're ready to print it, use printer.EndDoc.

kain_mcbride 12 Light Poster

loop it (any kind of loop will do, if you don't use a For Next loop, just add a counter variable and increment it each time) though i'm assuming you have these employees in an array of some sort..? if you print the index value you're using to access the name and employee number, you can just print that. then use Format$ to add the . if you want it there.

kain_mcbride 12 Light Poster

yeah; i didn't actually give an answer, i just explained the question... if you follow the link the wording of the question could use some work; i did list a way to do part 3, but the method isn't an acceptable sollution to the question, just the way i'd do it (if i was doing it for some other purpose than to answer a question).

kain_mcbride 12 Light Poster

Hi there..
I am new member here and having a problem.
I am working with a software solution co. and we want our software to support "Internationalization". means want to provide multilingual support.

We are using vb6.0 as development and all the diff APIs for our working.....
can anyone tell me how I can provide Unicode (UTF - 8) support to my project?
I can not develop it from scratch (no chance). do anyone know any 3rd party tool or API that will help me keep the UTF - 8 (stop vb to convert it into ANSI.. or something like that)...
and give me say arabic language in my object.

Pl help me I am in real trouble and on the deadline...

Thanks in advance.
-Rrajal

try using a resource file, you can specify different string sets for different languages... i've not done this before though; but when working with resource files that's one of the primary suggested reasons for using them...

Resouce Files can be added to a VB6 project with the add-in manager, just go through the list until you find it. once there you can add resource files to your project. a resource file can contain pictures, strings, or data... data can be anything from movies to garbage files...

as for unicode... have you looked at StrConv?

StrConv(String, Conversion as vbStrConv, [LocaleID as Long])

hope this helps...

kain_mcbride 12 Light Poster

Hi,

im doing a program in VB and i want to print my clients information.

But i dont want to print a printscreen of the form, i want to print a list of all my clients on a page design by me, i know that is possible to design the print page in acess but i dont know how to do it on VB and how to select by code, the number of clients that i want printed on the list.

well, there are different ways to use the printer; i don't really remember them off hand. the standard way isn't as easy as one would like, but it'll work...

to test this, and save on paper; i suggest that you create a picture box and print to it using the same method shown here; only difference is the EndDoc; don't use that with a picturebox

anyway, on to the code...

now, i'm assuming you have some kind of client list; so i thought i'd make one up just for a visual...

Private Type myCLIENTS
 stName as String * 32
 stHomePhone as string * 10
 stWhatever as string * 32
End Type

Private Clients() as myCLIENTS
Private iPage as Integer

I happen to like Types, you might notice this if you look at any of my other posts...
anyway, in my sample that i wrote and tested with, i hard coded the variables in a sub i called 'SET_CLIENTS'

Private Sub SET_CLIENTS()
 ReDim Clients(1 …
kain_mcbride 12 Light Poster

alright, what part aren't you understanding?

part 1 is creating 5 arrays and setting their values somewhere within the program.

part 2 is creating another 3 arrays to store the results of your comparisons between the data.

part 1 is basicly just putting the data into the arrays; you can hard code this within the program if you want since the data is fixed for this question. hardcoding data could be set in the form_load sub, or you could create another sub 'setData' or something and call it from Form_Load

part 2 is taking that data and compairing it.
so, if actualSales > targetSales, commissionAmount would be (commissionPercentage / 100) * actualSales * 1.5

then you'd add commission amount with basic salary to make total salary

and since actual sales exceed target sales, you'd set targetAchieved to "EXCEEDED"

if actualSales = targetSales then commission isn't modified, just applied in a similar way to above
same as above; except targetArchived would be "MET"

if actualSales < targetSales, then they don't get a commission.
same as above, except target achieved would be "FAILED"

and finally part 3

part 3, you just put everything in a list box with columns. personally i don't see the purpose in using a list box; they're not exactly functional... but thats what you were asked to do; so i guess that's what you're going to have to do.

(this does not apply to your homework, this …

kain_mcbride 12 Light Poster

alright, what part aren't you understanding?

part 1 is creating 5 arrays and setting their values somewhere within the program.

part 2 is creating another 3 arrays to store the results of your comparisons between the data.

kain_mcbride 12 Light Poster
Private x As Integer
Private fakeDate As Long

Private Sub chkMonth_Click(Index As Integer)
 txtMonths.Text = ""
 For x = 1 To 12
  If chkMonth(x).Value = vbChecked Then
   fakeDate = DateSerial(1, x, 1)
   txtMonths = txtMonths & Format$(fakeDate, "MMMM ")
   MsgBox x
  End If
 Next x
End Sub

please ignore the

MsgBox x

listed within the code...

(edit)Sorry, i didn't notice the edit this post button until just now...(/edit)

kain_mcbride 12 Light Poster

I work in a project with 12 chekbox(12 monthname) and a textbox. when I check a box a month
name like "january" show in textbox. when I check another checkbox "February" show in that
textbox after january. like "January February" as like same 12 checkbox. but when I uncheck
any checkbox the textbox become blink. coz I write code
if check1.value = 1 then
text1.text = "january"
else
text1.text = ""
end if
if check1.value = 1 and check2.value = 1 then
text1.text = "january February"
end if
I write it with a module. but I want when I uncheck a checkbox it will erase that monthname
others monthname will show in textbox. if there is any other way to do this like listbox,
or other then help me please or help me with this project.

hello; this is probably a bit of an overkill; but when i was thinking about it, then testing it; i didn't actually write the months in the checkboxes. so if you were going to actually list the month name as the check box caption; i guess you could get the month name from there...

as i said, i did it a little differently...

Private x As Integer
Private fakeDate As Long

Private Sub chkMonth_Click(Index As Integer)
 txtMonths.Text = ""
 For x = 1 To 12
  If chkMonth(x).Value = vbChecked Then
   fakeDate = DateSerial(1, x, 1)
   txtMonths = txtMonths …
kain_mcbride 12 Light Poster

ok,
ive got a combobox. ill tell you some choices that are in it. :

vacant lot
seaside lot
casino
shopping mall

when you click one of these, they are connected to the same variable. because im figuring one problem at a time, the choice which you choose is now connected to a variable, this variable is put into an equation and figured. each choice will have two things attached to it.
its monetary value, and itself, like its own name.

but im not exactly sure if it can be done.

also, each option must be able to show itself in an output, as a string

personally, i'd create a type, could be public or private, going to go public for now...

public type lotStyle
 stLot as string
 cPrice as currency
end type

Public LotStuff() as lotStyle

then you can set your values, or load them from a file

public sub SetValues_hardCoded()
 redim LotStuff(1 to 4)
 
 LotStuff(1).stLot = "vacant lot"
 LotStuff(1).cPrice = 5000
 LotStuff(2).stLot = "seaside lot
 LotStuff(2).cPrice = 10000
 LotStuff(3).stLot = "casino
 LotStuff(3).cPrice = 100000
 LotStuff(4).stLot = "shopping mall
 LotStuff(4).cPrice = 150000
end sub

- or -

public sub SetValues_fromFile(stFileName as string)
 open stFileName for random as #1 len=len(LotStuff)
 
 dim x as integer
 for x = 1 to lof(1) / len(LotStuff)
  ReDim preserve LotStuff(1 to x)
  get #1, x, LotStuff(x)
 next x
end sub

- then -

Private Sub Form1_Load()
 'this assumes that the variable information has already been loaded... …