Text Entries
This is what i have so far
Code: Open "edittext.txt" For Output As #1 Open "originaltext.txt" For Input As #2
x = 1 Do While Not EOF(1) Input #2, UserName, UserID If Not NewUser.User.Selected(nIndex) = UserName Then Write #1, UserName, UserID End If x = x + 1 Loop Close #1 Close #2 It doesn't write anything to text.txt , can anyone tell me what is going on??
Also, how do i rename edittext.txt to originaltext.txt. I think i have to kill originaltext.txt first.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Text Box Entries
I have put several Text Box's on a Form and assigned this as Text in the Text Box's property sheet "[- Available -]". When I try to Type something in th TextBox it won't do it nothing Happens. Do I have to erase what's in the Box and Then Type or What?
Saving Text Box Entries
Is there a way to save the entry in a text box so that the next time the user form is entered the text that was entered the last time appears in the text box?
For example, when my VBA user form pops up I ask for the company name and their website which they enter into a text box. Is there a way for that information to be there when they open the word document in the future?
Thanks.
Mike
Multiple Entries In 1 Text Box
I need help doing something with a text box. Heres the situation... I have a command that brings a text box visible to the form. I then want the user to input say "5" into the text box... and then hit a command that says add which takes that number to a label called total... then if the user has another number to put into the text box, the first one entry deletes after the add command is pushed and the user can put another entry in the same text box. Say the number is "4", then the add command is pushed again deleting the "4" and adding it to the 5 previously in the label. Can somebody help me with pseudo code?
Textbox Entries To Show Latest Appended Entries.
How do set a textbox to show the latest appended entry? When data is appended to a text box it always resets to the top of the window. To view the appended data one must scroll down. I would like to keep the latest viewable. Any ideas, please?
Saving Text Entries In UserForms
I am using VBA in Reflection, a terminal emulator software. I am building a UserForm to replace a series of input boxes that the user is currently being prompted for. The input boxes have code to save the last entry in the box so that the user does not have to re-enter the same data every time. Is there a way to use code for each text box in a UserForm to store the last entered data, until the user changes it?
Thanks
To Check For Blank Entries In A Text Box
Hi friends
First of all let me introduce myself, I am Peters A P. I just started learning VB.
I have a question regarding the following
I have a form, where I want to enter alphanumeric values in the text box and then it should update to the database.
The form has around 25 text boxes, out of which I need to enter complusorily for 10 textboxes. How do I check that and give an error message if I forget to enter one value in one textbox.
I am pasting part of codes below, here I am checking for text1.box whether it is blank, similarly, i need to check for 9 more text boxes. How do I do that
Private Sub cmdSave_Click()
Dim contactrec As New ADODB.Recordset
contactcon.Open "smmdetails"
Set contactrec = contactcon.Execute("Select * from smm_details")
If contactrec.BOF = True Then
If txtBox1.Text = "" Then
MsgBox "Please enter Name of the Firm"
Else
contactcon.Execute ("insert into smm_details(name_of_company, type_of_business, ho_address, ho_city, ho_country, " & _
"ho_tel_no_1, ho_tel_no_2, ho_fax_no_1, ho_fax_no_2, ho_email_1, ho_email_2, ho_website, ho_contact_person, ho_contact_person_mobile, " & _
"local_address, local_city, local_country, local_tel_no_1, local_tel_no_2, local_fax -no, local_email, local_contact_person, local_contact_person_mobile, " & _
"sponsor_name, sponsor_tel_no_1, sponsor_tel_no_2, sponsor_fax_no_1, sponsor_mobile_no, sponsor_email, owner_name, owner_tel_no_1, owner_mobile_no, " & _
"owner_passport, owner_nationality, owner_passport_expiry) Values('" & txtBox1.Text & "')")
End If
Else
MsgBox "Record Already Exists"
End If
contactrec.Close
End Sub
Reverse Entries In A Text File
Hi all..
I have a program I wrote that outputs abnormal program activity to a text file.
Example: Say user tries to choose a non-existant path:
message= "Path error encountered."
Goes to a sub called logme:
sub logme
open "errorlog.txt" for append as #1
print #1, message
close 1
Pretty simple I know.
But what if I wanted to limit the errorlog.txt file size to 100 entries?
Is there a simple way to delete entry #1 when entry #101 is made?
Currently program counts the number of lines in the file before writing to it. If over 100 then it copies everything except entry #1 to another file (erorlog.tmp). It then adds entry 101 to errorlog.tmp.
It then deletes errorlog.txt, renames errorlog.tmp to errorlog.txt. This results in 100 entries, first in-first out.
There has got to be a cleaner way to do this, and I know you are the guys to ask.
Thanks.
Find Previous Entries In Text Box
You know guys how on internet explorer if you previously have entered a string in a text box it remembers every value that has been entered before in that text box and gives you the list. For instance if you are trying to login to a website you start typing your user name. Let's say my user name is hespinoza. If I type "h" then in the list will appear all entries begining with "h" If I type "e" then the list will filter its contents and only display values that start with "he" Does anyone has something that would help me figure this thing out?
Thanks a bunch.
Removing Duplicate Entries In A Text File
I have an email list that has an email address on each line. The problem is that some emails appear more than once in the file.
I'd like to parse out the dups and create a file of non-dups and a file of all the dups
here' the code I have and it sure isn't working. Maybe my brain isn't working right today
Code:
set objFS=CreateObject ("Scripting.FileSystemObject")
set listFile = objFS.OpenTextFile ("BADEMAILS.txt")
set listFile1 = objFS.OpenTextFile ("BADEMAILS1.txt")
set logfile = objFS.CreateTextFile("Final-Removed.txt")
set logfile1 = objFS.CreateTextFile("Final-Removed-dups.txt")
count = 1
do while listFile.AtEndOfStream <> True
line1 = listFile.ReadLine
count1 = 1
listFile1.open
do while listFile1.AtEndOfStream <> True
line2 = listFile1.ReadLine
if line1 <> line2 then
logfile.writeline line2
else
logfile1.writeline line2
end if
count1 = count1 + 1
Loop
listFile1.close
count = count + 1
Loop
BADEMAILS.txt and BADEMAILS1.txt are identical. The only way I could think is to open one file and walk down each line while looping through a different file with the same content parsing out the dups?
Any help would be appreciated
Thanks
Deleting Double Entries In Text Files. How To?
hello,
I have a text file with the following information:
name, address, phone number
I want to use vb to delete entries with the same name, so I would
have only the latest updated information about that name.
how can I do this with vb?
thanks
Remove Duplicate Entries From Text File....
hi, say i have a textbox with numbers like this:
345
645
878
8978
585
64
3
56
how would i make a program which removes duplicate entries from the textbox? i've more or less got a similar bit of code working which works for a listbox, but i'm kinda stuck with how to do it on a textbox. can anyone help?
[solved] Sorting Entries In Text Files
foe example i have a text file named mydbs.txt
the entries inside it are
anything 12.00
others 65.65
helpme 56.76
anyone 96.65
schizo 44.44
how do i get the entries to be sorted where the highest entry is on the top of the file...
Print Text Box Entries To Seperate .txt File
I am very new to VB and am currently trying to work out how to copy each answer from a text box into a .txt file. For instance name and address details. Can anyone help ?
Thanx in advance,
Putting Text File Entries Into An Array
Hey all!
OK, what I want to do is put a whole bunch of names into an array from a text file. The names are already in correct order, all I want to do is get entry #1 into label #1, entry #2 into label #2 etc. How do I do this?
This is what I've got, but I know it doesn't work.
Code:
Private Sub Form_Load()
Dim Name as String, i as String
Open "c:lennycollingwoodfilesPlayers.txt" For Output As #1
For i = 1 To 52
Input #1, Name
lblPlayer(i).Caption = Name
Name = ""
Next i
End Sub
Thanks in advance for any help you can offer.
Multiple Text Box Entries On Form To Array
Can anyone help. I have multiple text boxes on a form, and I want the code to go through each text box and put the text in to a 2D array.
The text boxes are created after the user input the number of verticies, 2 verticies creates 4 text boxes done with this code
Private Sub Form_Load()
Dim ctlName As Control
Dim TBox_name As String
Dim Tbox_value As String
Dim i As Integer
Dim Top As Integer
i = 0
Top = 500
TBox_name = "Text"
For i = 0 To Verticies - 1
Tbox_value = CSng(i + 1)
TBox_name = TBox_name + Tbox_value
Set ctlName = Form4.Controls.Add("VB.TextBox", TBox_name, Form4)
ctlName.Visible = True
ctlName.Top = Top * (i + 1)
ctlName.Left = 500
ctlName.Width = 700
ctlName.Height = 200
Tbox_value = CSng(i + 2)
TBox_name = TBox_name + Tbox_value
Set ctlName = Form4.Controls.Add("VB.TextBox", TBox_name, Form4)
ctlName.Visible = True
ctlName.Top = Top * (i + 1)
ctlName.Left = 1700
ctlName.Width = 700
ctlName.Height = 200
Next
Form4.Height = (Top * (i + 1)) + 500
End Sub
Thanks for your help.
Iain
Deleting Duplicate Entries In A Text File
okay here is my code...i can load the file and add to it and close it and i know how to check for duplicate items, but how can i delete the duplicate entry....
private Sub Form_Load()
Dim Temp as string
lstClient.Clear ' clear current entries
Open "C:
ame.txt" for input as #1
Do Until EOF(1)
Line input #1, Temp
lstClient.AddItem Temp
Loop
Close #1
lblDisplay.Caption = lstClient.ListCount
End Sub
private Sub cmdClose_Click()
Dim X
Open "C:
ame.txt" for Output as #1
for X = 0 to lstClient.ListCount - 1
print #1, lstClient.List(X)
next X
Close #1
Unload me
End Sub
thanx in advance
midnight service
Need A Code That Alowes Entries In Text Boxes To Be Saved
Hi,
I am very new to VB..
I'm hoping some of you might be able to help me make a code to apply in text boxes made in MS Word 2000..
I have made a document with several text boxes, and saved it as a web page.
When I open the document in IE, I can add text in the boxes, and print it out.
What I would like is to be able to save the webpage with the entered text still in the boxes...
When I save now, and reopen, the boxes are empty..
Any hints?
Brgds André
Collect The Entries Made In A Text Box In A Variable After Each Execution
code for the following steps
1.Declare a variable globally say Var_NEW
2.Store the value in a text field in the variable Var_NEW everytime with a terminating string like ‘;’
3.For Ex: if the text is entered for first time, then the variable holds like VAR_DSN=<FIRST_NAME>; second time VAR_DSN=<FIRST_NAME>;<SECOND_NAME>;
Deleting Double Entries In Text Files. How To? *Not Solved*
I tried with no success to delete double entries in a text file.
I'll explain, I have a text file with the following information:
name, address, phone number
I want to use vb to delete entries with the same name, so I would
have only the latest updated information about that name.
previous help also did not work...
http://www.vbforums.com/showthread.p...hreadid=304157
so I'm still not in my happy place...
any help?
Search/Replace In Text File Based On Database Entries.
I'm writing an application to take a text file and run a find and replace function on the text based on some entries in a database. Say you have a text file that is comprised of thousands of lines that are formatted pretty similarly (comma delimited). I want it to read through the lines and every time it comes across the Product type of Equifax Infile, to change the Category to Developed Report. And for all Products that are undefined (else) the Category should be set to Developed Report. The categories and products are saved in a database that is editable by the user. The Product table contains a foreign key to link to the Category table so as to create a one-to-many relationship. As I am pretty new to the whole programming world, any help anyone could provide would be appreciated. I have sample code and text file if you would like. Please let me know if you have any ideas for this function. Thank you very much for your help.
Convert More Than 255 Column Entries Of Database, Originally From Tab Delimited Text File
I was looking to convert the data in a tab delimited text file, which when expanded would run upto 295 columns in a ms-access database(two table in access) or two excel worksheets in msexcel. Since the data is tab delimited I am encountring few problems in deciphering the logic. I am using this piece of code for this entire process. CAN ANYBODY HELP ME WITH THIS....Please
PS: the line where variable k checks on numbers is to check the last field in each table defined in local array I find errors hitting when there is a zero-length character in the text field. str(k)="" looks for those.. also there are date datatype defined in the msaccess database there is type mismatch error occuring due to this zero length character as the tab count in the text file increases by 1 always!!
Code:Dim rs As New ADODB.Recordset
Dim tabb As Variant
Dim i As Integer
On Error Resume Next
tabb = Array("Universal_Form", "Employee_Data", "Spouse", "First_Dependent", "Second_Dependent", "Third_Dependent", "Fourth_Dependent", "Fifth_Dependent", "Life_Group", "Health_Questions", "Explanation_1", "Bankers_Life_Insurance")
Set tx = fso.OpenTextFile(App.Path & "/S1UN003.txt", ForReading)
While Not tx.AtEndOfStream
Stop
str = Split(tx.ReadLine, vbTab, , vbTextCompare)
If UBound(str) < 295 Or UBound(str) > 295 Then Exit Sub
j = 0
i = 0
For k = 0 To UBound(str)
If Not k = 36 Or k = 39 Or k = 55 Or k = 71 Or k = 87 Or k = 119 _
Or k = 135 Or k = 181 Or k = 209 Or k = 227 Then
If tabOpen = False Then
rs.Open "SELECT * FROM " & tabb(j), con, 2, 3
If j = 2 Then Stop
rs.AddNew
If str(k) = "" Or IsNull(str(k)) Or str(k) = " " Then
If rs.Fields(i).Type = adDate Then
Stop
Else
rs.Fields(i) = Null
End If
Else
rs.Fields(i) = str(k)
End If
tabOpen = True
Else
If str(k) = "" Or IsNull(str(k)) Or str(k) = " " Then
If rs.Fields(i).Type = adDate Then
Stop
Else
rs.Fields(i) = Null
End If
Else
rs.Fields(i) = str(k)
End If
End If
i = i + 1
If k = 37 Or k = 40 Or k = 56 Or k = 72 Or k = 88 Or k = 104 Or k = 120 Or k = 136 Or k = 182 Or k = 210 Or k = 252 Or k = 295 Then
rs.Update
rs.Close
tabOpen = False
j = j + 1
i = 0
Else
rs.Update
End If
End If
Next k
Wend
Set tx = Nothing
Help On Displaying Certain Text As A Label In A Form Based On All Entries In Status Field
I have a ExamTaken Table that has the following fields:
1. ExamID as Primary Key
2. ExamDate
3. Score
4. Status. The status field has a combo box that gives two choices Pass or Fail. The status field actually stores an ID which is ID="5" for Pass
and ID = "4" for Fail.
My Question. I have a form that displays all exam ID, the score, date and status. I have a Lable named lable13 at the top of the Form that displays a text msg "Overall Result: "
What I need to do is, if all the status in the status field is Pass then Me.Label13.Caption = "Overall Result: Passed" and If any of the status field is set to Fail then the Me.Label13.Caption = "Overall Result: Failed"
So if there are 6 exam ID and the status field for each ID is selected as Pass then the Label13 should display "Overall Result: Passed" however if any of the status field is selected as Fail for any exam ID then the label13 should display "Overall Result: Failed"
I have included a sample database to give a better understanding on what I am trying to achieve.
Thanks for all you response,
Ket
VB To Check For Entries/not Entries On A Form
Helooo
I've been writing a reporting tool in Excel. I have hit upon a problem though. One part of the tool is a form users fill in to log system faults at work. Unfortunatley, if they leave a field blank, it buggers up the way the tool works later in the report.
I need to have a Sub that can look at each of the 5 cells, and either fill them in with something like "Not-set" or bring up a message box and stop the macro, so the user can fill it in.
Below is the code I'm trying to use.....
The problem is, once the code reaches the 'Call saveandupdate' command, the next Sub starts, and if there is more than one blank field, it is ignored....
Can anyone help, or suggest an alternative?
Thankus Muchus.
Chris~
Code:
Function validateCell(celladdress As String) As Boolean
If IsEmpty(Range(celladdress).Value) Then
validateCell = False
Else
validateCell = True
End If
End Function
Sub validateAll()
Const issue = "E12"
Const custnum = "F12"
Const Timedate = "G12"
Const ISP = "H12"
Const IP = "E17"
Const Notes = "F17"
Dim valid As Boolean
initialise:
valid = True
If Not validateCell(issue) Then
valid = False
Range("issue").Select
ActiveCell.Formula = "Not set"
End If
If (valid = True) And (Not validateCell(custnum)) Then
valid = False
Range("F12").Select
ActiveCell.Formula = "Not set"
End If
If (valid = True) And Not validateCell(Timedate) Then
valid = False
Range("G12").Select
ActiveCell.Formula = "Not set"
End If
If (valid = True) And Not validateCell(ISP) Then
valid = False
Range("H12").Select
ActiveCell.Formula = "Not set"
End If
If (valid = True) And Not validateCell(IP) Then
valid = False
Range("E17").Select
ActiveCell.Formula = "Not set"
End If
If (valid = True) And (Not validateCell(Notes)) Then
valid = False
Range("F17").Select
ActiveCell.Formula = "Not set"
End If
' Call SaveandUpdate
End Sub
Word: Using Word To Spell Check Text Entries
I have posted a reply to a previous thread but as the last entry to the thread is pretty old I am not sure if it is still active, so have posted a new thread too. Apologies if this is not the correct protocol!
I am new to this forum and want advise on a previous post (see Martin’s original http://www.vbforums.com/showthread.php?t=246451).
I have applied Martin's code (its excellent!) to my application (VB6, Office 2003 under XP). It all works fine apart from one annoying behaviour I cannot figure. When the Word spell checker form is displayed, it does not always appear at the front of the screen. But this behaviour is inconsistent - sometimes it does, and sometimes not and I have been unable to identify why this variation is occurring.
Is there a foolproof method of forcing the spell checker form to the front of the display area when the spell checking is invoked so that the user sees the spell check form but not the “dummy” document containing the text to be spell checked?
DNS Entries
Anyone know how to get the DNS entries? (ie: get the dns server(s) that the computer your app is running on, should use to resolving)
on my computer "HKEY_LOCAL_MACHINESystemCurrentControlSetServicesVxDMSTCP" has an entry of "NameServer" and it as both of them, but that entry isnt documented anywhere.
Deleting Entries In A Txt
This is how I add entries to the txt file:
Code:
Open "text.txt" For Append As #1
Write #1, UserName.Text, UserID.Text
Close #1
'next, UserName will be placed in a list box
Open "text.txt" For Input As #1
x = 1
Do While Not EOF(1)
Input #1, UserName, UserID
List1.AddItem UserName 'the list box displays the data as check boxes
x = x + 1
Loop
Close #1
what code do i use to delete the selected entries from the list box and the txt file??
Registry Entries For My App
Hello again
When I want to install my app I use InstallShield 5.5. I've never really paid much attention to registry settings, however. My question is this: where should I store my application registry settings for my install? For example, I've noticed the SetSetting/GetSetting functions in VB only change keys under the HKEY_CURRENT_USER/HKEY_USERS keys. When I install my app on a machine should my app's registry entries by under HKEY_LOCAL_MACHINE? (I'm using Nt4.0 BTW)
Cheers
Simon
Duplicate Entries...
Hello!
I have a file in which i want to find weather duplicate entries exist or not..please tell me how to do it propeerly ?
I was created the following code but it did'nt worked:
please help! Also i know the code following is not good and efficient please suggest an efficient code.
Thanks!
Code:
Dim AddExist As Boolean
Open "c:emails.txt" For Input As #1
Do Until EOF(1)
AddExist = False
Line Input #1, A
On Error GoTo FileNotFound:
Open "C:TempEmails.txt" For Input As #2
Do Until EOF(2)
Line Input #2, B
If B = A Then AddExist = True: Close #2: GoTo FileNotFound:
Loop
Close #2
FileNotFound:
If AddExist = False Then
Open "C:TempEmails.txt" For Append As #3
Print #3, B
Close #3
End If
Loop
Close #1, #2, #3
MsgBox "Duplicates Removed!"
Registry - Want To See If Any Entries
I need to know if there are any Registry Entries when my application is run ( that way I can tell if this is the first time a user has run my program )
Obviously I can check a particular entry by using:
Code:
GetSetting(App.Title, "Settings", "Entry", "Value")
but it would be much neater if I could just check whether my application has any Registry Entries at all by checking the value of something or other ( Ideally I would like to avoid APIs as my prog is already too big )
Many thanks!
Registry Entries
My app has certain parameters that can be user customized. I have a table in my access db that holds these parameters. Is this a good idea, or should I use the Registry to hold these?
My first thought on this was that it would be nice to have as few supporting files as possible. It would be great if I could only have two files - the exe and the db.
Max Entries In Combo Box
After reading an interesting post about the maximum number of entries in a List Box, I decided to research the maximum number of entries for a Combo Box. All I did was this:
1. Add a Combo Box to a Form, Style was set to 2 - Dropdown List.
2. Add a Command Button to the Form.
3. Add the following code:
Code:
Option Explicit
Dim y As Long
Private Sub Command1_Click()
Combo1.AddItem y
y = y + 1
End Sub
Private Sub Form_Load()
Dim x As Long
For x = 1 To 32735
Combo1.AddItem x
Next x
y = x
End Sub
Maximum number of entries that can be places in a Combo box is 32,736. Try to add another and you get:
Runtime Error '5'
Invalid procedure call or argument.
(odd message if you ask me)
Anyways, now to my Interface question. I have 20,000+ entries I will be placing in a Combo Box. They are SS#'s, and the users are used to typing in the numbers but I want to ensure that a valid SS# is selected. My problem is that we expect to reach the Combo Box limit within a year. How would you handle the situation?
Or..... Should I just forget populating the Combo box with valid SS#'s, allow the user free key entry, validate the length of the entry, and then validate the SS# against the database? Hmmm, may have answered my own question. LOL
Oh well. Use the knowledge of the limitations of the Combo Box. Think I will go with my brainstormed solution. Thanks for helping.
Duplicate Entries
hi passel, i really need help in this game....my deadline is on friday n i need sorting out....this is my game codind..i need help on how to code for 3d) where the user inputs the snakes and ladders positons between 5 to 10 and how to save that reference.
Code:
Option Explicit
Dim dice As Single
Dim p1 As Integer
Dim temp As Integer
Dim chance As Integer
Dim STACK As Integer
Dim throwcount As Integer
Dim gamenum As Integer
Dim gamecount As Integer
Dim snakeindex(1 To 10) As Integer
Dim snakevalue(1 To 10) As Integer
Dim ladderindex(1 To 10) As Integer
Dim laddervalue(1 To 10) As Integer
End If
If p1 = 100 Then
MsgBox "CONGRATULATIONS YOU WIN"
MsgBox throwcount
gamecount = gamecount + 1
p1 = 0
End If
'End If
Else
MsgBox "YOU HAD HAD ENOUGH OF PLAY. SIT DOWN N DO SOME WORK."
gamenum = 0
End
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
throwcount = 0
Dim i As Integer
Dim found12 As Boolean
Dim counter As Integer
Dim pos As Integer
Dim throw As Integer
Dim chk As String
throw = 0 'throws is set to 0 on load up
chance = 0 'chance is set on 0 on load up
p1 = 0 'player 1 is set on 0 on load up
STACK = 0 'stack is set on 0 on load up
counter = 1 ' counter is set at 1 on load up
pos = 0
chk123:
chk = InputBox("How many games you want to apply")
For i = 1 To Len(chk)
If Mid(chk, i) > "A" And Mid(chk, i) < "Z" Then
found12 = True
End If
Next
If found12 = True Then
MsgBox "you must enter a numerical value"
GoTo chk123
Else
gamenum = Val(chk)
End If
gamecount = 1
End Sub
Option Explicit
Dim dice As Single
Dim p1 As Integer
Dim temp As Integer
Dim chance As Integer
Dim STACK As Integer
Dim throwcount As Integer
Dim gamenum As Integer
Dim gamecount As Integer
Dim snakeindex(1 To 10) As Integer
Dim snakevalue(1 To 10) As Integer
Dim ladderindex(1 To 10) As Integer
Dim laddervalue(1 To 10) As Integer
If p1 = 100 Then
MsgBox "CONGRATULATIONS YOU WIN"
MsgBox throwcount
gamecount = gamecount + 1
p1 = 0
End If
'End If
Else
MsgBox "YOU HAD HAD ENOUGH OF PLAY. SIT DOWN N DO SOME WORK."
gamenum = 0
End
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
throwcount = 0
Dim i As Integer
Dim found12 As Boolean
Dim counter As Integer
Dim pos As Integer
Dim throw As Integer
Dim chk As String
throw = 0 'throws is set to 0 on load up
chance = 0 'chance is set on 0 on load up
p1 = 0 'player 1 is set on 0 on load up
STACK = 0 'stack is set on 0 on load up
counter = 1 ' counter is set at 1 on load up
pos = 0
chk123:
chk = InputBox("How many games you want to apply")
For i = 1 To Len(chk)
If Mid(chk, i) > "A" And Mid(chk, i) < "Z" Then
found12 = True
End If
Next
If found12 = True Then
MsgBox "you must enter a numerical value"
GoTo chk123
Else
gamenum = Val(chk)
End If
gamecount = 1
End Sub
if you can post a reply as soon as possible..as i got annotations to finish as well.
thanks
Duplicate Entries
I'm having the same kind of problem, but I'm not, I'll explain.
If a player types in 23 for the position of the snake, and they then type in 23 for the number of spaces for it to go back, I want a message box to appear saying that it cannot as it would mean the snake going off the board. Now I've got my second array, it's called GameRules.
Code:
Private Sub SnakeRules()
Do While Snakeslength <= 9 Or Snakeslength >= 31 'Start of loop, will stop when Snakelength is no longer more than 30 or less than 10'
If Snakeslength >= 31 Or Snakeslength <= 9 Then 'Start of loop, says that if Snakelength is over 30 or lesser than 10, something will occur'
MsgBox ("The distance of the Snake must be between 10 and 30") 'A message box appears stating the number must lie between 10 and 30'
Snakeslength = InputBox("Please enter the Snakes length between 10 and 30") 'An input box appears, asking the question asked first, but stating the requirements'
End If 'Ends loop'
Loop 'Ends loop'
Do While GameRules(Snakeslength) <> 0
If GameRules(Snakeslength) < 0 Then
Snakeslength = MsgBox("Position entered")
Else
If GameRules(Snakeslength) > 0 Then
Snakeslength = InputBox("A Snake cannot go off the board")
End If
End If
Loop
End Sub
Private Sub LadderRules()
Do While Ladderlength <= 9 Or Ladderlength >= 31 'Start of loop, will stop when the Ladderlength is no longer more than 30 or less than 10'
If Ladderlength >= 31 Or Ladderlength <= 9 Then 'Start of loop, says that if Ladderlength is over 30 or lesser than 10, something will occur'
MsgBox ("The length of the Ladder can only be between 10 and 30") 'A message box appears stating the number must lie between 10 and 30'
Ladderlength = InputBox("Please enter length of Ladder between 10 and 30") 'An input box appears, asking the question asked first, but stating the requirements'
End If 'Ends loop'
Loop 'Ends loop'
Do While GameRules(Ladderlength) <> 0
If GameRules(Ladderlength) < 0 Then
Ladderlength = MsgBox("Position entered")
Else
If GameRules(Ladderlength) > 0 Then
Ladderlength = InputBox("A Ladder cannot go off the board")
End If
End If
Loop
End Sub
in english, i want it something like this
if number of spaces the player goes back means the player going off the board, then a message box will appear, saying to input an appropiate number,
Duplicate Entries
Right program is now 98% complete and dead line is tomorrow at 12.15 =O
This is for my Snakes And Ladders and also for future programs that I'm going to start creating as im addicted to vb anyways different story.
On my Snakes and ladders game the user is asked to input locations of the snakes and ladders on the board.
E.g. of this could be a Snake head on cell 41 and a ladder on cell 53.
So to explain what I want(hope the title helepd there)
I want it so the user cant have a Snake on cell 41 and a ladder on cell 41.
So from what I so far worked out is I need two arrays.
This is code so far.
Code:
Do
If SHead = LadderTop Then
MsgBox Cannot have a Snake Head on a Ladder!"
Else
MsgBox "This is valid please continue"
Exit Do
End If
Loop
However I know that code above should work, however how would I include it into my play button in which the user enters the position of the snakes and ladders without the message just appearing even if they are in different cells.
My code for play button is in attachment.
Calculating New Entries
I need a little bit of help. I have two columns, lets call them A and B. I would like to be able to enter new data into either column and have it recalculated, B=A*150 or A =B*150, into the other, even if it means overwritng the previous data. The problem is that when I enter the data into column A or B the computer calculates A first and then B. That causes all the new data in B to be overwritten by the calculated data coming from B. Here is an example:
I first enter the data:
A B
0.345
21
30
30
0.52
Instead of the answers looking like this:
A B
0.345
0.1421
304500
0.230
0.52 78
It looks like this:
A B
0.345
00
304500
00
0.52 78
The zeros in column A cause the zeros in column B when calculated. I have tried to have an entry column but I don't need an extra column because I already have too many. Is there anything that can fix this. Maybe a function that can calculate upon entry of new data? Thanks.
Brian
Double Entries
Afternoon
I am having a problem with one of my macro's. I have a excel main sheet and all the months on a different sheets in the same document. On the main sheet i have a end date and the macro takes the end date and copies that line to the correct month. Now if i go into the document tomorrow and add loads more line in the master documents and then press go it re-sorts and copies all the line even the old ones into the months making double entries. Is there a way to for it to check or stop making the double entries and only add the new lines.
Here is the code i have for sorting it:
Code:
Option Explicit
Const CountColumn = 15 ' the column in which the count formula is to be entered
Private Sub Go_Click()
Dim currentMonth, intLimit, intX, intCurrentRow As Integer
Dim months
months = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
ThisWorkbook.Sheets("January").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("February").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("March").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("April").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("May").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("June").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("July").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("August").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("September").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("October").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("November").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("December").Cells(1, CountColumn) = "=count(A:A)+1"
ThisWorkbook.Sheets("Master").Cells(1, CountColumn) = "=count(A:A)+1"
Dim tmpSheetName As String
intLimit = Int(ThisWorkbook.Sheets("Master").Cells(1, CountColumn).Value)
For intX = 2 To intLimit
currentMonth = Int(ThisWorkbook.Sheets("Master").Cells(intX, 14).Value) - 1
tmpSheetName = months(currentMonth)
Sheets("Master").Select
ActiveSheet.Range("A" & intX & ":M" & intX).Select
Selection.Copy
Sheets(tmpSheetName).Select
intCurrentRow = Int(ThisWorkbook.Sheets(tmpSheetName).Cells(1, CountColumn).Value) + 1
ActiveSheet.Range("A" & intCurrentRow).Select
Selection.PasteSpecial (xlPasteAll)
Next intX
End Sub
Help would be appreciated.
Thanks
Grid Entries
Dear All,
I am using MSFlexGrid Control for entries in the detail section of the forms( which has master-detail logic). I do it by superimposing the text box/combo box on the grid control, which i find too cumbersome and inconvenient.
There are many custom Active X controls like TrueDBGrid control or Spread Control available for this purpose in the market. I am sure there might be many others.
I would like to change to one of these controls. I am not able to decide on what to change to. I would like to know ur valuable opinion and suggestion on what to use based on your experience.
My preference is faster development and easy to learn.
Array With No Entries
I set up an array like:
DIM MyArray() as string
In the program I may or may not REDIM and load the array.
If OK then
REDIM PRESERVE MyArray(0 to entries)
MyArray = Str$(entries)
entries = entries + 1
End If
The problem is when the array has never been REDIM'd.
When I try to access the array, the program stops with Subsript out of range.
When I check the value of MyArray while stepping through the program,
it shows a value of Nothing. How can I test for Nothing?
If MyArray <> Nothing then '<<<<<< This does not work
For i = 0 to Ubound(MyArray)
List1.Additem MyArray(i)
Next i
End If
Thanks
jim
.... .. .... ..
List Entries
Hi All,
I want to enter data into multi columns and it will be multi rows also. The number of rows are not fixed. Can I do that with ListView? If so How? I want it to be some thing like in Microsoft Money, where they have split/multi catagories. When you select this you are directed into another window where you can enter with same catagory in multiple lines. I want to enter the data in the following manner.
Location | Qty | Amount |
______________________________|
__________|__________|________||
__________|__________|________|
_______________________________
Total :
There will be different locations with different qty with the same catagory. Any idea how I can achieve this?
RegSvr And Its Entries
Hello
Is it possible to display all entries made by RegSvr, I guess they are placed in the register. What I mean is something like the reference dialog in de VB ide.
I hope someone can help me
Deleting Entries
i'm trying to figure out how i can delete the entries in a column in a database, and i haven't figured it out yet....
got any clues that might direct me in the right direction ?
Displaying Last Entries
I am working in Access 2002. I want to display the last 15 entries into a table by way of a form. The results then need to be displayed in a Message Box. I am pretty sure I want to use a sort, descending order. What I can't figure out is how to restrict the display to the last 15 entries made. This is what I have so far:
Private Sub Last15_Click()
Dim rs As ADODB.Recordset ' Declares rs as ADO Recordset
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection ' Creates open connection to database
Set rs = New ADODB.Recordset
rs.ActiveConnection = cnn1 ' Sets cnn1 as data location for rs
rs.CursorLocation = adUseClient
Dim SQL As String
SQL = "SELECT Layout.id, People.name, [dbo_wrk grp].txt, dbo_ProcedureMain.ProcGroup, dbo_ProcedureMain.ProcNum, dbo_ProcedureMain.ProcName, Periods.Period, Layout.DLC, Layout.DNC FROM Periods INNER JOIN ([dbo_wrk grp] INNER JOIN ((Layout INNER JOIN People ON Layout.Personid = People.id) INNER JOIN dbo_ProcedureMain ON Layout.SOPid = dbo_ProcedureMain.id) ON [dbo_wrk grp].[wg id] = Layout.Deptid) ON Periods.ID = Layout.Periodid WHERE (((Layout.id)=" & Me.id & "));"
rs.Open SQL
rs.Sort = (rs.Fields(1)DESC)
MsgBox (rs.Fields(1))
rs.Close
cnn1.Close
End Sub
At the moment, I get a Syntax Error on the rs.Sort line.
Thanks.
Michael Heiter
Registry Entries
Hi,
Do you actually need to create registry entires when you install an application or - if you've already created them on your own machine - does the packaging wizard do this for you?
Grouping Entries
ok here is what i have.
i have 2 listboxes.
The first one holds about 20 entries.
I randomly re-order that one, and then send the re-ordered list to my second listbox.
here is what i want to do...
when i send the list to the second listbox, i need to seperate the entries into groups of three.
I want each group to be seperated by a space
example:
List1
entry1
entry2
entry3
entry4
entry5
entry6
List2
entry1
entry2
entry3
<--the space
entry4
entry5
entry6
<--and i need another here(and so on)
thanks
Registry Entries
Hi,
I'm looking for a way to pull up multiple registry entries without knowing their names. All the 'Run' Keys for example.
Thanks in advance.
Registry Entries
How I write registry settings in vb other than in HKEY_CURRENT_USERSoftwareVB and VBA Program Settingsappnamesectionkey registry location ?
Anajnesh
|