P.manidas 39 Posting Whiz in Training

Probably, you have done spelling mistake somewhere or something else. Without observing your codes, we can't help you. So, its better to post your save button's codes and table's field name.

P.manidas 39 Posting Whiz in Training

Here is your needed codes. Enjoy coding and mark the thread close.

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<style>
</style>
</head>
<body>
<h1><font color="blue">Maths Game</h1></font>

<script type="text/javascript">

var score = 0;
var ua = new Array();
var ca = new Array();
var xa = new Array();
var ya = new Array();
var opa = new Array();
var dispa = new Array();

//================
var AllCombine = new Array();
var MyString;
//================

var ops = ["+","-","*"];


function showResult()
{
var cnt = dispa.length;
for(var i=0;i<cnt;i++)
{
 //document.write("<br />"+dispa[i]+ " = " + ua[i]);
 MyString = dispa[i]+ " = " + ua[i];  //============================
 if(ua[i]!=ca[i])
 {
  //document.write(" is incorrect - <span style='color:red'>The correct answer is " + ca[i] + "</span>");
  MyString += " is incorrect - <span style='color:red'>The correct answer is " + ca[i] + "</span>";//======
 }
 else
 {
  //document.write(" <span style='color:green'>The answer is correct</span>");
  MyString += " <span style='color:green'>The answer is correct</span>"; //=================
  score += 2;
 }
AllCombine.push(MyString);//=================================
}
ua = new Array();
ca = new Array();
xa = new Array();
ya = new Array();
opa = new Array();
dispa = new Array();

}


for(var i=0;i<10;i++)
{
 var x = Math.floor(Math.random()*101);
 var y = Math.floor(Math.random()*101);
 if(x<y)
 {
  var temp = x;
  x = y;
  y = temp;
 }
 xa.push(x);
 ya.push(y);
 op = ops[Math.floor(Math.random()*ops.length)];
 var disp = x +" "+op+" "+y;
 dispa.push(disp);
 var v = prompt("How much is " + disp + " ?");
 ua.push(v);
 ca.push(Math.round(eval(disp)));
 showResult();
}
//=============================================
for(var i=0;i<10;i++)
{
document.write("<br />" + AllCombine[i]);
}
//==============================================
document.write("<br />Your score: " + …
P.manidas 39 Posting Whiz in Training

Dear Thepanther,

Ok, its not complicated. But, I have a question for you, have you written those codes or copied from somewhere? If you copied from somewhere and asking all help from other then you can't increase your knowledge. The better way is doing some parts yourself and ask help for some parts.

Anyway, I am telling you how to do that...


1. Declare 2 nos. of variables, one is String and other is Array.
2. Concatenate the display line into String variable like ("50*2=150" + "is incorrect - The Correct answer is 100") or ("63+11=74" + "The answer is correct").
3. After that you push the string variable's value into the Array variable.
4. In last display the Array variable's value using for loop.

Give a try to solve.....

P.manidas 39 Posting Whiz in Training

Dear Thepanther,

I think you have not understood what i have said. Anyway, i am making for you little bit easier..

1. Replace this line "var score = 0;" from line no. 71 to 14 or 24 as per your first post
2. In the line no. 73 there is background colour as Red replace it with Yellow.

P.manidas 39 Posting Whiz in Training

Dear thepanther, I have seen your codes, there is nothing wrong. Just place your score variable initialization before showresult function. And change the background colour to yellow.

P.manidas 39 Posting Whiz in Training

Wrong Answer.

P.manidas 39 Posting Whiz in Training

Find the Numbers.......

A teacher says: I'm thinking of two natural numbers greater than 1. Try to guess what they are.
The first student knows their product and the other one knows their sum.
First: I do not know the sum.
Second: I knew that. The sum is less than 14.
First: I knew that. However, now I know the numbers.
Second: And so do I.
What were the numbers?

P.manidas 39 Posting Whiz in Training

The above puzzle is very tough to solved. But any way, The solution is ..

Here,
1 -> 11 (One 1)
11 -> 21 (two 1)
21 -> 1211 (one 2 and one 1)
1211 ->111221 (one 1, one 2 and two 1)
111221 ->312211 (three 1, two 2 and one 1)

Suppose there there is a no. 5861155
for fist digit (5) that is ONE 5 =15
for second digit (8) that is ONE 8=18
for third digit (6) that is ONE 6=16
for forth and fifth digit (11 (though both the digit is same)) those are TWO 1=21
for sixth and seventh digit (55 (though both the digit is same)) those are TWO 5=25

So, the number is 1518162125

Arbus commented: Right answer! +0
P.manidas 39 Posting Whiz in Training

Try this 4 lines of code instead of line nos. of your codes 7 to 11

txtINameS.Text = Myrs("ItemNameSize").Value
If Myrs.RecordCount = 0 then
MsgBox "No Record Foun.Try again"
Endif
P.manidas 39 Posting Whiz in Training

The number is 2519

Arbus commented: Perfect! +0
P.manidas 39 Posting Whiz in Training

Try this one

Dim Complete As Boolean = False
Dim Com As Boolean= False
Dim PlaceNum As String
Dim i As Integer
Dim j As Integer

Dim Num1 As Integer=1
Dim Num2 As Integer=1


Do While Complete = False
If listbox1.Items.Count > 1 Then
For j = 0 To listbox1.Items.Count - 2 Step 1
    PlaceNum = listbox1.Items(j)
    For i = j + 1 To listbox1.Items.Count - 1 Step 1
        If PlaceNum = listbox1.Items (i) Then
            Num1 = Num1 * Val(listbox1.Items (i))
            listbox1.items.RemoveAt (i)
            listbox1.items.RemoveAt (j)
            Complete = False
            Com = True
            Exit For
        Else
            Com = False
        End If
     Next i
     
     If listbox1.Items.Count = 1 Then
     Complete = True
     Exit For
     End If
     
     If Com = True Then
        Exit For
     End If
     
     If j = listbox1.Items.Count - 2 Then
        Complete = True
     End If
Next j
Else
Complete = True
End If
Loop

For i = 0 To listbox1.Items.Count - 1 Step 1
Num2 = Num2 * listbox1.Items (i)
Next i

Textbox1.Text = Num1
Textbox2.Text = Num2
tstory28 commented: The code was right on the nose. He figured out exactly what I needed. +1
P.manidas 39 Posting Whiz in Training

By this below codes you can check how many words are there on single line or multi line text box even if user enter space in between and before or after words.

Private Sub Command1_Click()
Dim Counts As Integer
Dim dupText As String

dupText = Replace(Trim(Text1.Text), vbNewLine, " ")

If dupText = "" Then
    Counts = 0
Else
    Counts = 1
    For i = 1 To Len(dupText)
        If Mid(dupText, i, 1) = " " Then ' use Mid to search space
            If Mid(dupText, i - 1, 1) <> " " Then
                Counts = Counts + 1
            End If
        End If
    Next
End If
MsgBox Counts
End Sub
debasisdas commented: agree +12
dnk commented: Thanks for duplicate checking :) +2
WaltP commented: and thanks for doing his homework for him. Now he doesn't have to think. -3
P.manidas 39 Posting Whiz in Training

Dear Twigan1015,

I am sorry but confused what you are asking here. What i understand is...

You have four column/Field UPC, Quantity, Price and Total. You want to add all these four column's data into a listbox as listitem. And after that you will save it into a text file. And whenever it needed the data of text files, you will retrieve into a listbox.

For calculating purpose which field/column' data you will provide as input data? As i understand you will provide only UPC and Quantity. What about price of quantity?

Let us know it clearly.

P.manidas 39 Posting Whiz in Training

Adding 7 nos. textbox's text into a listbox

lstAlbums.Items.Add(Form1.textbox1.text.ToString)
lstAlbums.Items.Add(Form1.textbox2.text.ToString)
lstAlbums.Items.Add(Form1.textbox3.text.ToString)
lstAlbums.Items.Add(Form1.textbox4.text.ToString)
lstAlbums.Items.Add(Form1.textbox5.text.ToString)
lstAlbums.Items.Add(Form1.textbox6.text.ToString)
lstAlbums.Items.Add(Form1.textbox7.text.ToString)

For saving a listbox item into a text file

'for saveing listitem into text file
Dim Objfile As New System.IO.StreamWriter("C:\TestText.txt")
Dim intCounter As Long 
For intCounter = 0 To lstAlbums.Items.Count - 1
    objFile.WriteLine(lstAlbums.Items(intCounter).ToString)
Next intCounter

Objfile.Close()
Objfile.Dispose()

Retrieving textfile(i.e list items saved in the text file) into listbox on form load event

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Reading and adding into a listbox
Try
   Dim objFile As New System.IO.StreamReader("c:\TestText.txt")
   Dim strAlbumName As String
   strAlbumName = objFile.ReadLine()
   Do Until strAlbumName Is Nothing
        LstAlbums.Items.Add(strAlbumName)
        strAlbumName = objFile.ReadLine()
   Loop
   objFile.Close()
   objFile.Dispose()
   Catch ex As Exception
      MsgBox("The file could not be found.")
   End Try
End Sub

in my codes Listbox name is lstAlbums

P.manidas 39 Posting Whiz in Training

If you want to add list item of listbox1 of from1 to listbox1 of Form2

write the below codes in form2_load event....

Dim a As Integer
ListBox1.Items.Clear()
For a = 0 To Form1.ListBox1.Items.Count - 1 Step 1
    ListBox1.Items.Add(Form1.ListBox1.Items.Item(a).ToString)
Next

If you want to add textbox's text of from1 to listbox1 of Form2

write the below codes in form2_load event....

ListBox1.Items.Clear()
ListBox1.Items.Add(Form1.textbox1.text.ToString)
ListBox1.Items.Add(Form1.textbox2.text.ToString)
ListBox1.Items.Add(Form1.textbox3.text.ToString)
ListBox1.Items.Add(Form1.textbox4.text.ToString)
ListBox1.Items.Add(Form1.textbox5.text.ToString)
P.manidas 39 Posting Whiz in Training

You need four digit number after "MR/IR/", so you have to keep your field like MR/IR/0001, MR/IR/0002 .... MR/IR/0997, MR/IR/0998 then it will increase to MR/IR/0999, MR/IR/1000, MR/IR/1001 so on, up to MR/IR/9999.

If you keep your filed MR/IR/001, MR/IR/002 -- MR/IR/999. It will give error like "Argument length must be greater or equal to zero".

see it and check it.

P.manidas 39 Posting Whiz in Training

You have to change the filed data MR/IR/001 --- MR/IR/999 to MR/IR/0001 -- MR/IR/0999 in your database then my codes will works. --- for first 2 line changer code

you can check by changing the last records filed MR/IR/999 to MR/IR/0999

And same as for three line changer also...

P.manidas 39 Posting Whiz in Training

Dear Igho,

I have tested and it works fine.

If you need counter MR/IR/0001 to MR/IR/9999

Try this codes as i modify two lines ....

dtReader = cmd.ExecuteReader
If dtReader.Read Then
strTemp = Mid(dtReader.Item("IDPERIKSA"), 7, 4)

Else
'TxtDETAILTRANS.Text = "MR/IR/001" 
TxtDETAILTRANS.Text = "MR/IR/0001" 'change here
Exit Sub
End If
msgBox(strTemp)
strValue = Val(strTemp) + 1
'TxtDETAILTRANS.Text = "MR/IR/" & Mid("000", 1, 3 - strValue.Length) & strValue 
 TxtDETAILTRANS.Text = "MR/IR/" & Mid("0000", 1, 4 - strValue.Length) & strValue ' change here

or If you need counter MR/IR/00001 to MR/IR/99999

Try this codes as i modify three lines....

dtReader = cmd.ExecuteReader
If dtReader.Read Then
'strTemp = Mid(dtReader.Item("IDPERIKSA"), 7, 4)
strTemp = Mid(dtReader.Item("IDPERIKSA"), 7, 5) ' change here

Else
'TxtDETAILTRANS.Text = "MR/IR/001" 
TxtDETAILTRANS.Text = "MR/IR/00001" 'change here
Exit Sub
End If
msgBox(strTemp)
strValue = Val(strTemp) + 1
'TxtDETAILTRANS.Text = "MR/IR/" & Mid("000", 1, 3 - strValue.Length) & strValue 
 TxtDETAILTRANS.Text = "MR/IR/" & Mid("00000", 1, 5 - strValue.Length) & strValue ' change here
P.manidas 39 Posting Whiz in Training

Dear Androidz,

I had also started a thread as similar as to your thread. I have got the result. Probably you will also get the result from that. The thread is :

Addition of number from dynamically created textboxes after inputted by user

P.manidas 39 Posting Whiz in Training

This is an example with listbox for getting your solution. Hope, it will solve your problem.

Dim A As Integer = 0

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        A = A + 1
        If Trim(TextBox1.Text) = Trim(Now) Then
            ListBox1.Items.Add(Now & " " & A)
        Else
            A = 1
            ListBox1.Items.Add(Now & " " & A)
        End If
        TextBox1.Text = Now
    End Sub
swathys commented: thank you +0
P.manidas 39 Posting Whiz in Training

Whin Lopez, As the code of Vanzhyme worked for you, mark this thread as solved, found at the bottom of this page.

P.manidas 39 Posting Whiz in Training

Satti, in my earlier reply i have told you to use my code in the lostfocus of keydown event of txtExpense3 textbox but you use in text1 and text2's change event. Not like that. Use these whole code.

after using these code reply again. I am in Online.

Private Sub txtExpense3_LostFocus()
Text2.Text = Val(txtCommision.Text) + Val(txtRent.Text) + Val(txtLabour.Text) + Val(txtReturnExpense.Text) + Val(txtExpense2.Text) + Val(txtStoreExpense.Text) + Val(txtPhoneExpense.Text) + Val(txtExpense3.Text)
Text1.Text = Val(txtNetPrice) - Val(Text2.Text)
End Sub
P.manidas 39 Posting Whiz in Training

Write down the below code in the text field's (txtexpense3) lostfocus or keydown event. In your code txtexpense3 is written as txtexpemse3

Text2.Text = Val(txtCommision.Text) + Val(txtRent.Text) + Val(txtLabour.Text) + Val(txtReturnExpense.Text) + Val(txtExpense2.Text) + Val(txtStoreExpense.Text) + Val(txtPhoneExpense.Text) + Val(txtExpense3.Text)
Text1.Text = Val(txtNetPrice) - Val(Text2.Text)
P.manidas 39 Posting Whiz in Training

Dear Trilok31,

You are right sir, Thanks for modification. I think, now ben25x has got the solution for his thread. Thanks...

P.manidas 39 Posting Whiz in Training

Try this one....

Creating a button

Private Sub Form_Load()
Dim Com As CommandButton
Set Com = Me.Controls.Add("vb.commandbutton", "BtnName")

    With Com
        .Left = 1000
        .Top = 3000
        .Width = 5000
        .Height = 1000
        .Visible = True
        .Caption = "My Button"
    End With
End Sub

Moving a button.....

Dim CmdX As Long
Dim CmdY As Long
Dim MoveBtn As Boolean


Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
CmdX = X
CmdY = Y
MoveBtn = True
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MoveBtn Then
    Command1.Top = Command1.Top - (CmdY - Y)
    Command1.Left = Command1.Left - (CmdX - X)
End If
End Sub

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveBtn = False
End Sub