通过多次单击将多个数字添加到Visual Basic中的值

时间:2017-12-14 20:43:17

标签: vb.net

在Visual Basic中我想添加多个数字,多次点击我的值,所以我使用了这个方法,但它没有像订购那样 这是它应该如何显示结果1 - > 3 - > 7 - > 15 - > 31 - > 63 - > 127 但它就像这样1 - > 3 - > 11并在此停止

我认为当我的价值达到6时,它不会更进一步。

这是我的方法:

Public Class Form1

    Dim a As Integer = 0
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Label1.Text = (Str(a))

        Select Case (a + 1) * 2 - 1


            Case 0
                a += 1
            Case 1
                a += 2
            Case 2
                a += 4
            Case 3
                a += 8
            Case 4
                a += 16
            Case 5
                a += 32
            Case 6
                a += 64


        End Select

    End Sub

End Class

1 个答案:

答案 0 :(得分:0)

以下内容对您有用:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@ page import ="java.sql.*" %>
<%@ page import ="javax.sql.*" %>
<% 
String user = request.getParameter("user");
//session.putValue("user",user);
String pwd = request.getParameter("pwd");

Class.forName("com.mysql.jdbc.Driver");
//it returns com.mysql.jdbc.Driver.class. 

 
   java.sql.Connection conn = 
   DriverManager.getConnection("jdbc:mysql://localhost:3306/employeeexample", "root","1234");
   Statement stmt = conn.createStatement();
   
   String query = "SELECT * FROM users2 WHERE user_id ='"+ user + "'";
	
	out.println("Query: "+query);
	ResultSet rs = stmt.executeQuery  (query);
	out.println("<br/><br/>Results");
	
	while(rs.next()){
		String s = rs.getString("user_id");
		out.println("<br/><br/>\t\t"+s);
	}

/*
	if(rs.next())
{
	if(rs.getString(2).equals(pwd)){
		out.println("welcome "+user);
		 out.println("SELECT * FROM users2 WHERE user_id ='"+ user + "'");
	}
	else{
		out.println("WRONG PW!!! TRY AGAIN");
		
	}
}
 */ 
   %>
   <a href ="index.html"> Home </a>
   

</body>
</html>

注意:您可能希望更改两个语句的顺序 - 这取决于您是否要在第一次显示Public Class Form1 Dim a As Integer = 0 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Label1.Text = Str(a) a = (a + 1) * 2 - 1 End Sub End Class 时,或者是否要首次显示0