列表框填充特定行

时间:2016-08-22 03:47:06

标签: excel vba listbox userform

我想仅使用特定行从数据库填充vba列表框。 这就是我得到的。

Private Sub UserForm_Initialize() 

Hoja2.Activate
ListBox1.ColumnCount = 5
ListBox1.ColumnWidths = "70;90;90;90;70"


ListBox1.AddItem "FIRST NAME"
ListBox1.List(0, 1) = "LAST NAME" 
ListBox1.List(0, 2) = "LAST NAME 2"
ListBox1.List(0, 3) = "BORN DATE"
ListBox1.List(0, 4) = "AGE"


Dim seguimiento As Integer
Dim i As Integer

seguimiento = Application.WorksheetFunction.CountA(Range("b:b"))

For i = 1 To seguimiento
    If Cells(i, 20) = "" Then
    ListBox1.AddItem Cells(i, 3)
    Else
    End If
Next i

End Sub`

1 个答案:

答案 0 :(得分:0)

实际上很难理解你问题中的列表框填充标准

假设您要使用单元格填充列表框:

  • 在列“T”单元格不为空的行
  • 将第2行中的行扫描到“B”列
  • 中的最后一个非空行
  • 通过“G”
  • 从列“C”获取值

尝试以下代码:

public class OpenGLProjectRenderer implements Renderer {

List<Float> points = new ArrayList<Float>();

private static final String TAG = "Renderer";
private static final int POSITION_COMPONENT_COUNT = 2;
private static final int BYTES_PER_FLOAT = 4;
private FloatBuffer vertexData = ByteBuffer
        .allocateDirect(20000 * BYTES_PER_FLOAT)
        .order(ByteOrder.nativeOrder()).asFloatBuffer();
private Context context;
private int program;

private static final String A_POSITION = "a_Position";
private int aPositionLocation;

private static final String U_COLOR = "u_Color";
private int uColorLocation;

private HashMap<Integer, ArrayList<Float>> lines = new HashMap<Integer, ArrayList<Float>>();
int position = 0;

public OpenGLProjectRenderer(Context context) {

    this.context = context;
}

@Override
public void onDrawFrame(GL10 gl) {
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glUniform4f(uColorLocation, 1.0f, 0.0f, 0.0f, 1.0f);

    for (int p = 0; p < lines.size(); p++) {

        vertexData.put(toFloatarray(lines.get(p)));
        int vertices = (int) lines.get(p).size() / 2;
        int b = vertices % 4 == 0 ? vertices-1 : vertices - 2;
        Log.d(TAG,""+lines.size());
        glDrawArrays(GLES20.GL_LINE_LOOP, 0, lines.size());
        vertexData.clear();
    }

}

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);

}

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    String vertexShaderSource = TextResourceReader.readTextFileFromResource(
            context, R.raw.simple_vertex_shader);
    String fragmentShaderSource = TextResourceReader.readTextFileFromResource(
            context, R.raw.simple_fragment_shader);

    int vertexShader = ShaderHelper.compileVertexShader(vertexShaderSource);
    int fragmentShader = ShaderHelper
            .compileFragmentShader(fragmentShaderSource);
    program = ShaderHelper.linkProgram(vertexShader, fragmentShader);
    ShaderHelper.validateProgram(program);
    glUseProgram(program);
    uColorLocation = glGetUniformLocation(program, U_COLOR);
    aPositionLocation = glGetAttribLocation(program, A_POSITION);
    vertexData.position(0);
    glVertexAttribPointer(aPositionLocation, POSITION_COMPONENT_COUNT,
            GL_FLOAT, false, 0, vertexData);
    glEnableVertexAttribArray(aPositionLocation);
}

ArrayList<Float> temp = new ArrayList<Float>();

public void handleTouchPress(float normalizedX, float normalizedY) {
    Log.v(TAG + " handleTouchPress", points.size() + "");       

    temp.add(normalizedX);
    temp.add(normalizedY);

    lines.put(position, temp);
}

public void handleTouchDrag(float normalizedX, float normalizedY) {

    Log.v(TAG + " handleTouchDrag", points.size() + "");
}

public float[] toFloatarray(List<Float> floatList) {

    float[] floatArray = new float[floatList.size()];
    int i = 0;

    for (Float f : floatList) {
        floatArray[i++] = (f != null ? f : Float.NaN);
    }

    return floatArray;
}

public void handleTouchUp(float normalizedX, float normalizedY) {
    Log.v(TAG + " handleTouchUp", points.size() + "");

    position++;

}}